Jump to content
L.R.A

TM4C129 Hibernation RTC and Calendar Mode

Recommended Posts

by the way, it's also possible to get interrupts in the 1/32768 ticks of the crystal but since i haven't realy have tested sometigh solid let's leave that for later :P

 

But there's the info for anyone that wants to investigate hat

Share this post


Link to post
Share on other sites

Looking at the TM4C1294 Connected LaunchPad schematic, there is a populated resistor you might be able to remove in order to source VBAT separately, but you'd be surface-soldering a wire to a tiny resistor pad in order to do so...

http://www.ti.com/lit/spmu365 - page 31, see "VBAT" and resistor R38.  But it'd be much nicer if there was a PTH pad attached to VBAT so you could easily include a non-boosterpack-standard pin on a custom BoosterPack which provides an alternate VBAT source.  (side note- I'm sending feedback to TI asking for this feature in future revisions or models of the Tiva series)

Share this post


Link to post
Share on other sites

by the way there is sometigh you can implement to "simulate having the vbat".

 

If you use a diode with a 3V batery and you power the launchpad with 3.3V you can actualy always power the launchpad even when the main power goes out.

you "waste" a ADC to check the voltage supply, if it's 3V or bellow then you enter sleep mode.

 

The diode is simply to only alow the 3V batery to power the launchpad when the main power supply stops

Share this post


Link to post
Share on other sites

I tested this before in the tm4c123 to work with the crystal ticks istead of 1 second interrupts. This should generate a interrupt every 0,000030517578125 seconds (1/32768)

 

There's is just 1 problem, if the counter is about to overflow in the next tick, the interrupt will not work properly. inside the interrupt you have to control that. if the SS counter is at 32767 out of 32768 ticks then you have to set the interrupt value of SS to 0.

HibernateEnableExpClk(F_CPU);
HibernateRTCEnable();
 
 
This will set the interrupt to every second:
HibernateRTCSSMatchSet(0,HibernateRTCSSGet()+1);
HibernateIntRegister(HibernateHandler);
HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0);
 
and here is the interrupt function:
void HibernateHandler(void)
{
//Use this to reset interrupt flag
uint32_t ui32Status = HibernateIntStatus(1);
HibernateIntClear(ui32Status);

//Place here code to execute every second, ex: LCD or 7 segment display
//Altough it should be as fastest as possible


//To keep the interrupt hapening every second you need this
HibernateRTCSSMatchSet(0,HibernateRTCSSGet()+1); 
}

Share this post


Link to post
Share on other sites

To use in tm4c123 you can just do this to turn on the RTC:

 

HibernateEnableExpClk(F_CPU);

HibernateRTCEnable();

 

 

This will set the interrupt to every second:

HibernateRTCMatchSet(0,HibernateRTCGet()+1);

HibernateIntRegister(HibernateHandler);

HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0);

 

and here is the interrupt function:

void HibernateHandler(void)

{

//Use this to reset interrupt flag

uint32_t ui32Status = HibernateIntStatus(1);

HibernateIntClear(ui32Status);

 

//Place here code to execute every second, ex: LCD or 7 segment display

//Altough it should be as fastest as possible

 

 

//To keep the interrupt hapening every second you need this

HibernateRTCMatchSet(0,HibernateRTCGet()+1);

}

 

 

Tried the sketch here on the stellaris (lm4f120) launchpad: http://pastebin.com/a7p0dnt8

 

 

I found the blue and green leds to be too bright to clearly discern the red led so I pwm'ed the blue led to dim it, it is also furthest away from the red, much easier to tell when they are both lit or just one is lit etc.

You'd expect the red LED to blink forever and the blue to do the same. That works for a little while, but yet again I am finding that after an entirely random time period the red led stops blinking, yet the blue one carries on functioning so clearly the cpu is still running. The only thing I have found consistent between the time periods in which is takes to pause is that it will always finish with the red led being on, never off. Sometimes it only flashes once before stopping and sometimes it lasts a few minutes. Very strange.

Share this post


Link to post
Share on other sites

in the RTC setup try adding HibernateRTCTrimSet(0x7FFF);

I can't leave it running long enough to confirm that this is indeed a long term fix, but I've reached 300 seconds without crash for the first time so at this moment in time its looking like we're up and running

Share this post


Link to post
Share on other sites

I can't leave it running long enough to confirm that this is indeed a long term fix, but I've reached 300 seconds without crash for the first time so at this moment in time its looking like we're up and running

 

This was probably because the value wasn't set to default wich is 0x7FFF

Share this post


Link to post
Share on other sites

This was probably because the value wasn't set to default wich is 0x7FFF

Well the only code thats been on my launchpads has been from energia (without using hibernation) and the factory default so I dont know why it would be non default. But its fixed it, left it since 8am today and its still blinking.

Share this post


Link to post
Share on other sites

Well the only code thats been on my launchpads has been from energia (without using hibernation) and the factory default so I dont know why it would be non default. But its fixed it, left it since 8am today and its still blinking.

 

It's maybe a factory error.

I found a similar problem in a tm4c123

 

Glad it's solved

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...