MSP430-TIMER

Photo of author

By Jackson Taylor

Timer A in continues mode
— high speed blinking—0.059577273 seconds
Time  = (0xffff+1)/1.1MHz = 0.059578182
.include “msp430g2x31.inc”
org 0xf800                 
      mov.w #(WDTPW|WDTHOLD), &WDTCTL
      mov.w #0x280, SP
      mov.b #0x41,&P1DIR
      clr.b P1OUT  
      mov.w #(TASSEL_2|MC_2|ID_0|TAIE), &TACTL ;ID_0         eint      
jimmy:  jmp jimmy
TAISR:
      xor.b #0x41,&P1OUT
      bic.w #1,&TACTL                                        reti                          
ORG     0FFF0h                 
DW      TAISR    
ORG     0FFFEh                 
DW      0xf800  
1 second timer in continuous mode.
—using internal DCO (1.012829091 seconds)Time  = ((0xffff+1)/1.1MHz)*17 = 1.012829091  seconds…!!!
Here calculations are done assuming DCO = 1.1MHz
.include “msp430g2x31.inc”
org 0xf800                  
      mov #(WDTPW|WDTHOLD), &WDTCTL
      mov #0x280, SP
      mov.b #0x41,&P1DIR
      clr.b P1OUT  
      clr R5
      mov #(TASSEL_2|MC_2|ID_0|TAIE), &TACTL
      eint      
jimmy:  jmp jimmy
TAISR:
      inc R5
      cmp #17,R5
      jne exit
      xor.b #0x41,&P1OUT
      clr R5
 exit:
      bic #1, &TACTL      
      reti                          
ORG     0FFF0h                 
DW      TAISR    
ORG     0FFFEh                 
DW      0xf800  
Timer A — using up mode
high speed blinking
Time  = 51001/1.1MHz = 0.046364545
.include “msp430g2x31.inc”
org 0xf800                 
      mov #(WDTPW|WDTHOLD), &WDTCTL
      mov #0x280, SP
      mov.b #0x41,&P1DIR
      clr.b P1OUT  
      mov #(TASSEL_2|MC_1|ID_0|TAIE), &TACTL
      mov #51000, &TACCR0
      eint      
jimmy:  jmp jimmy
TAISR:     
      xor.b #0x41,&P1OUT  
      bic #1, &TACTL
      reti                          
org    0FFF0h                 
dw     TAISR    
org    0FFFEh                 
dw     0xf800