Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 03:29am 20 Oct 2014
Copy link to clipboard
Print this post
Hi
I have an odd problem with the PCF8563 RTC on the MicroMite, when I run the test code below which is a simple loop the CPU will only SLEEP on every other cycle ie:
SLEEP miss SLEEP miss SLEEP miss etc
The full code is far more complex but has exactly the same problem, I have tried various pauses FOR NEXT loops DO loops without success
Interval = 5 ' sets sleep time (integer value between 1 and 59 inclusive)
Pause 500: ?:? "Entering Loop":?:Pause 500
DO
StartInt
? "SLEEPING"
'
CPU SLEEP
'
? "AWAKE:"
LOOP
' ------------------------ SUBROUTINE -----------------------------------------------
SUB StartInt
I2C OPEN 100,100 ' open an i2c connection with bus speed 100KHz and 100mS timeout
I2C WRITE &H51, 0, 2, &H0F, Interval+1 ' pass Interval time to RTC timer register
I2C WRITE &H51, 0, 2, &H0E, &B10000010 ' Set Minutes OR Seconds: MINUTES=&B10000011 SECONDS=&B10000010
I2C WRITE &H51, 0, 2, &H01, &B00000001 ' reset any triggered flags and start the timer countdown
I2C CLOSE ' close 12c connection
END SUB
'----------------------------------------------------------- -------------------------
atmega8 Guru Joined: 19/11/2013 Location: GermanyPosts: 724
Posted: 03:44am 20 Oct 2014
Copy link to clipboard
Print this post
what stops the sleeping mode?
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 03:54am 20 Oct 2014
Copy link to clipboard
Print this post
Interval is set to 20 secs when time expires INT pin changes state - active LOW (connected to MicroMite WAKEUP pin)
Sorry 5 secs in the test codeEdited by edu001 2014-10-21
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 06:51am 20 Oct 2014
Copy link to clipboard
Print this post
I think what you need to do is add a bit of a delay between the RTC waking the MicroMite and before you put it back to sleep.
You may find the Int pin still 'active'. After the line 'Print "AWAKE:" add Pause 500
See how that goes - you may need to 'experiment with the value of the Pause (increase and/or decrease until it works.
Let us know how you get on . . .
edit: The more I think about it, the more I am convinced this is the issue - simple test will prove me wrong (or right )Edited by WhiteWizzard 2014-10-21
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 07:16am 20 Oct 2014
Copy link to clipboard
Print this post
I have tried delays everywhere upto 5 secs I get the same thing, I have also tried using I2C Write to stop and start the clock (control/status 1 register)
atmega8 Guru Joined: 19/11/2013 Location: GermanyPosts: 724
Posted: 07:25am 20 Oct 2014
Copy link to clipboard
Print this post
What wakes him up?
He cannot wakeup himself without external help!
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 07:28am 20 Oct 2014
Copy link to clipboard
Print this post
Wakes which one up ?
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 07:30am 20 Oct 2014
Copy link to clipboard
Print this post
Ok here s another observation it always ignores the first cycle, I tried to programme a single sleep mode but it cycles twice before it sleeps
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 07:31am 20 Oct 2014
Copy link to clipboard
Print this post
RTC or CPU ?
atmega8 Guru Joined: 19/11/2013 Location: GermanyPosts: 724
Posted: 07:40am 20 Oct 2014
Copy link to clipboard
Print this post
The micromite..
Will the rtc trigger pin 16?
If so, you have external help;-)
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 07:48am 20 Oct 2014
Copy link to clipboard
Print this post
The micromite..
Will the rtc trigger pin 16?
If so, you have external help;-)
The RTC triggers PIN 43 (44 pin micromite) it all works, its a cycling issue, it does not sleep on every cycle
atmega8 Guru Joined: 19/11/2013 Location: GermanyPosts: 724
Posted: 08:38am 20 Oct 2014
Copy link to clipboard
Print this post
Your hardware setup is ok?
Pullups/downs...
Power supply ok?
Test another..
BobD Guru Joined: 07/12/2011 Location: AustraliaPosts: 935
Posted: 08:51am 20 Oct 2014
Copy link to clipboard
Print this post
The Wakeup input on the uMite is edge triggered in either direction.
What is the RTC INT pulse like?
Is it remaining low when triggered or is it a 16 millisecond pulse?
Have you actually measured that pin?
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 08:55am 20 Oct 2014
Copy link to clipboard
Print this post
I have recommended that edu001 monitors the RTC Int pin (active low) and waits for it to be at a high level before the SLEEP command is issued.
He is testing this now and carrying out other measurements.
With his findings we can then make our next batch of 'suggestions'
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 09:31am 20 Oct 2014
Copy link to clipboard
Print this post
Your hardware setup is ok?
Pullups/downs...
Power supply ok?
Test another..
Yes pullups are all ok the power supply is a very clean 3.31v
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 09:33am 20 Oct 2014
Copy link to clipboard
Print this post
Here is the output from the logic analyser
http://imgur.com/iCixP7L
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 09:39am 20 Oct 2014
Copy link to clipboard
Print this post
Can you do the test where you pulse a pin immediately before SLEEP and pulse the same pin immediately after SLEEP.
This then allows us to see where the program is at (in relation to the rising edge of the INT pin.
If you can post a zoomed in image so we can see timings and I2C detail then it could help resolve
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 09:59am 20 Oct 2014
Copy link to clipboard
Print this post
More info 3 images
http://imgur.com/fEaCaPm,zE9DGvA,xns6D4R
edu001 Regular Member Joined: 14/07/2014 Location: United KingdomPosts: 82
Posted: 10:08am 20 Oct 2014
Copy link to clipboard
Print this post
More info 3 images
http://imgur.com/fEaCaPm,zE9DGvA,xns6D4R
Missed one http://i.imgur.com/JPZuGMM.png
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2932
Posted: 10:18am 20 Oct 2014
Copy link to clipboard
Print this post
Brilliant.
Now can you sample 4 cycles (reduce the sleep time to something like 2 seconds) i.e. grab about 10seconds of sample and send the screen shot.
I don't need to see the I2C detail, but as long as I can see the INT pin level and the 'test' pin levels and their relative timings then that would be helpful (Leave I2C connected - will just be 'blips' in the screen grab).
Thanks Jed . . . .
Page 1 of 2
Print this page
The Back Shed's forum code is written, and hosted, in Australia.