EmbeddedRelated.com
Forums
Memfault Beyond the Launch

long delays and how to simulate them

Started by jgb_gt_84 April 7, 2005

I'm working on a project where I only need the MSP430 (probably a
'F423) to wake up once a day.  It looks like the longest I can sleep
though is 30s. (TimerA w/ 32k ACLK / 8, updown mode, count to 61440
then back to 0 and interrupt on CCIFG)  Any suggestions on how to get
a longer delay?  

Also how can I simulate this?  I've set up IAR/TI C-SPY to generate a
TimerA interrupt, but when the ISR reads TAIV to determine the
interrupt source, it always comes back 0.
Regards,
Joe








Beginning Microcontrollers with the MSP430

You don't read TAIV per se, you use it. TAIV is cleared on the first 
read. The best way to use it is:_

TA12_ISR:
       ADD         &TAIV,PC
       RETI
        JMP        TA1_ISR
        JMP        TA2_ISR
        RETI
        RETI      
          JMP      TA_OVF_ISR         ;You should be using the overflow

On the subject of long delays, these are typically executed as a lot mof 
short delays. The MSP430 is particularly good for this becuase of the 
DCO and very rapid wake-up (6usecs quoted, but typically about 
500nsecs). In your ISR you maintain a second, or even third long 
counter. using simply continuous count and rollover interruipt you get 
an interrupt every 16 seconds, so a single counter would itself roll 
over at  1048576 seconds, or 291 hours, so for a 24 hour interrupt you 
need a

TA_OVF_ISR::
             BIC      #TAIFG, &TACTL
             INC    &COUNTER                    ;16 SECOND INTERVAL 
COUNTER  
            CMP   #5400,&COUNTER         ;24 HOUR TEST
             JLO      SNOOZE                        ;IF NOT 24 HOURS 
BACK TO SLEEP
             BIC      #LPM3,0(SP)                  ;EXIT SLEEP ON RETI, 
WHEN OLD SR IS POPPED
SNOOZE:
             RETI

This is the entire thing, except for entering sleep mode. I would have 
the lowest possible DCO frequency on entry to sleep.

Al

jgb_gt_84 wrote:

>
>I'm working on a project where I only need the MSP430 (probably a
>'F423) to wake up once a day.  It looks like the longest I can sleep
>though is 30s. (TimerA w/ 32k ACLK / 8, updown mode, count to 61440
>then back to 0 and interrupt on CCIFG)  Any suggestions on how to get
>a longer delay?  
>
>Also how can I simulate this?  I've set up IAR/TI C-SPY to generate a
>TimerA interrupt, but when the ISR reads TAIV to determine the
>interrupt source, it always comes back 0.
>Regards,
>Joe
>
>
>
>
>
>
>
>
>
>.
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>
>  
>


----- Original Message ----- 
From: "jgb_gt_84" <jgb_gt_84@jgb_...>
To: <msp430@msp4...>
Sent: Thursday, April 07, 2005 2:20 PM
Subject: [msp430] long delays and how to simulate them


>
>
>
> I'm working on a project where I only need the MSP430 (probably a
> 'F423) to wake up once a day.  It looks like the longest I can sleep
> though is 30s. (TimerA w/ 32k ACLK / 8, updown mode, count to 61440
> then back to 0 and interrupt on CCIFG)  Any suggestions on how to get
> a longer delay?

Just set it to interrupt, say, every second, and use software counters to 
get your 24 hour delay.

Leon 


I think he wants to conserve power and only wake up every 24 hours....

At 12:55 AM 4/9/2005, you wrote:

>Just set it to interrupt, say, every second, and
use software counters to
>get your 24 hour delay.
>
>Leon

// richard (This email is for mailing lists. To reach me directly, please 
use richard at imagecraft.com) 


Not possible in any conventional MSP430 configuration I'm aware of. Of

course he could externally divide a 32.768kHz clock, or find a very low 
frequency stable oscillator, then using the divide by 8 internally he 
would need the input frequency to be 6.068Hz. Or set the input frequency 
to 6Hz and the overflow counter to 64800. Then, after dividing by 8 the 
clock frequency is 0.75hz, so 1/f = 1.333333333 * 64800 = 86400seconds 
or 24 hours.

Dividing the 32768 clock would probably be easier than trying to get a 
crystal that would neatly divide down to 6Hz. So divide the 32768 clock 
by 8192 externally to get 4Hz, divide this by 8 to get 0.5hz, or a 2 
second tick, the 43200 as a compare gives 24 hours. Of course you have 
probanly consumed more power in the external divider than would be 
consumed aking up for a few clock cycles, then going back to sleep 
again. using registers for the COUNTER, and to hold the COMPARE value, 
my orignal solution requires.

R4 is a counter to count Timera rollovers
R5 is the literal value that correponds to 24 hours
R6 is the bit pattern used to enter the currtent sleep mode

TA_OVF_ISR:
            BIC      #TAIFG, &TACTL          ;5clocks
            INC     R4                                     ;16 SECOND 
INTERVAL COUNTER 1Clk
            CMP   R5,R4                                ;24 HOUR TEST   
1clock
            JLO      SNOOZE                        ;IF NOT 24 HOURS BACK 
TO SLEEP  2 clocks
            BIC      R6,0(SP)                          ;EXIT SLEEP ON 
RETI, WHEN OLD SR IS POPPED  4 clocks
SNOOZE:
            RETI                                              ;5 clocks

18 clock cycles plus wake up time, executed every 8 seconds so in every 
hour this sequence is executed 450 times. assuming DCOCLK = 500kHz then 
the above routine, including the vector jmp table requires 23 clock 
cycles, or 46usecs, plus 6usec start up. procedure requires a total of 
52usecs every 8 seconds. LPM3 consumes around 2uA. run mode. Run mode at 
500kHz is nominally 210uA, so the mean consumption is (7,999,948* 2 + 52 
* 210)/8,000,000 or 2.001352uA. I haven't yet found a divider that draws 
less than 1.35nA, or a stable external oscillatro that draws less 
current either.

Al



Richard wrote:

>I think he wants to conserve power and only wake up
every 24 hours....
>
>At 12:55 AM 4/9/2005, you wrote:
>
>  
>
>>Just set it to interrupt, say, every second, and use software counters
to
>>get your 24 hour delay.
>>
>>Leon
>>    
>>
>
>// richard (This email is for mailing lists. To reach me directly, please 
>use richard at imagecraft.com) 
>
>
>
>.
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>
>  
>


Everyone, thanks for the replies.  You've confirmed what I had already
expected.  I thought someone might have had a clever idea I had not
thought of.
The TAIV issue is apparently a deficiency of the KickStart interrupt
simulation.
regards,
Joe

--- In msp430@msp4..., Onestone <onestone@b...> wrote:
> Not possible in any conventional MSP430
configuration I'm aware of. Of 
> course he could externally divide a 32.768kHz clock, or find a very low 
> frequency stable oscillator, then using the divide by 8 internally he 
> would need the input frequency to be 6.068Hz. Or set the input
frequency 
> to 6Hz and the overflow counter to 64800. Then,
after dividing by 8 the 
> clock frequency is 0.75hz, so 1/f = 1.333333333 * 64800 = 86400seconds 
> or 24 hours.
> 
> Dividing the 32768 clock would probably be easier than trying to get a 
> crystal that would neatly divide down to 6Hz. So divide the 32768 clock 
> by 8192 externally to get 4Hz, divide this by 8 to get 0.5hz, or a 2 
> second tick, the 43200 as a compare gives 24 hours. Of course you have 
> probanly consumed more power in the external divider than would be 
> consumed aking up for a few clock cycles, then going back to sleep 
> again. using registers for the COUNTER, and to hold the COMPARE value, 
> my orignal solution requires.
> 
> R4 is a counter to count Timera rollovers
> R5 is the literal value that correponds to 24 hours
> R6 is the bit pattern used to enter the currtent sleep mode
> 
> TA_OVF_ISR:
>             BIC      #TAIFG, &TACTL          ;5clocks
>             INC     R4                                     ;16 SECOND 
> INTERVAL COUNTER 1Clk
>             CMP   R5,R4                                ;24 HOUR TEST   
> 1clock
>             JLO      SNOOZE                        ;IF NOT 24 HOURS
BACK 
> TO SLEEP  2 clocks
>             BIC      R6,0(SP)                          ;EXIT SLEEP ON 
> RETI, WHEN OLD SR IS POPPED  4 clocks
> SNOOZE:
>             RETI                                              ;5 clocks
> 
> 18 clock cycles plus wake up time, executed every 8 seconds so in every 
> hour this sequence is executed 450 times. assuming DCOCLK = 500kHz then 
> the above routine, including the vector jmp table requires 23 clock 
> cycles, or 46usecs, plus 6usec start up. procedure requires a total of 
> 52usecs every 8 seconds. LPM3 consumes around 2uA. run mode. Run
mode at 
> 500kHz is nominally 210uA, so the mean consumption
is (7,999,948* 2
+ 52 
> * 210)/8,000,000 or 2.001352uA. I haven't yet
found a divider that
draws 
> less than 1.35nA, or a stable external oscillatro
that draws less 
> current either.
> 
> Al
> 
> 
> 
> Richard wrote:
> 
> >I think he wants to conserve power and only wake up every 24 hours....
> >
> >At 12:55 AM 4/9/2005, you wrote:
> >
> >  
> >
> >>Just set it to interrupt, say, every second, and use software
counters to
> >>get your 24 hour delay.
> >>
> >>Leon
> >>    
> >>
> >
> >// richard (This email is for mailing lists. To reach me directly,
please 
> >use richard at imagecraft.com) 
> >
> >
> >
> >.
> >
> > 
> >Yahoo! Groups Links
> >
> >
> >
> > 
> >
> >
> >
> >
> >
> >  
> >





Memfault Beyond the Launch