I2C not working after Sleep | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar
Please consider registering
guest
sp_LogInOut Log In sp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSS sp_TopicIcon
I2C not working after Sleep
August 8, 2016
10:00 pm
Avatar
LDBM
Member
Members
Forum Posts: 11
Member Since:
August 8, 2016
sp_UserOfflineSmall Offline

Hi,

I am trying to write a basic VI that performs some tasks (logging or just writing an RTC value to serial for now). When I power down the Arduino programmatically with the Sleep Mode Power Down vi, I can wake it up fine on INT0 (Pin2), but once I want to resume reading the RTC: nothing.  I suspect the I2C bus has to be re-enabled. This link touches on the topic (search for "Waking I2C" on the page), but I fail to see how to implement the Wire.begintransmission followed by wire.endtransmission with the current API to re-enable I2C communication with the slave (RTC).

    // wake slave up
    Wire.beginTransmission (SLAVE_ADDRESS);
    Wire.endTransmission ();
    
    delay (5);  // give it time to recover
    
    Wire.beginTransmission (SLAVE_ADDRESS);
    bla bla...

Thx

ldbm.

Hardware: Uno, RT1307

PS: is there a way to enable other Arduino sleep modes (where for instance Timer1 on Arduino would still be powered). They are just a different switch while coding directing into the Arduino environment. Thx.

August 9, 2016
2:13 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

You can use I2C Write Byte with write mode set to "Begin and End".  This will do a beginTransmission(), clock a byte, then endTransmission().  Having the byte clocked should not matter for waking up.

Also, for the Arduino sleep modes, the Compiler only implements SLEEP_MODE_PWR_DOWN but you can make your own APIs by following the help manual to implement other sleep modes if desired.

August 9, 2016
5:20 pm
Avatar
LDBM
Member
Members
Forum Posts: 11
Member Since:
August 8, 2016
sp_UserOfflineSmall Offline

Thx Steffan,

I did try that, but no success yet. I will give it another go.

On some examples, it seems like a good idea to not use the Disable / Enable Interrupt while the main code has awaken, but rather to destroy the Interrupt (on the interrupt Service routine), and re-define the Interrupt before going to sleep. Do you agree ? Or the Disable Enable good enough? Thx.

ldbm.

August 9, 2016
8:58 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

I dont think you need to destroy and re-define the I2C interrupts if thats what you are referring to.  There is some info here about an I2C slave powering down and waking back up: http://www.gammon.com.au/power

Seems like you should call begin again after wakeup.  Best think to do is write a simple sketch in the Arduino IDE to figure out how to wake it up properly then port it over.

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
11
Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
miche91: 33
scottj: 28
scadao: 23
Member Stats:
Guest Posters: 5
Members: 202
Moderators: 0
Admins: 3
Forum Stats:
Groups: 1
Forums: 2
Topics: 266
Posts: 1222
Newest Members:
pujacontrol
Administrators: geadmin: 22, filipealtoe: 96, Steffan: 356