# Timer 100mSec

**URL:** <https://forums.digi.com/t/timer-100msec/10121>\
**Category:** Rabbit\
**Created:** [July 8, 2008, 9:27am UTC](https://forums.digi.com/t/timer-100msec/10121 "2008-07-08T09:27:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![User1104](https://avatars.discourse-cdn.com/v4/letter/u/73ab20/32.png) [@User1104](https://forums.digi.com/u/User1104)\
**Post date:** [July 8, 2008, 9:27am UTC](https://forums.digi.com/t/timer-100msec/10121/1 "2008-07-08T09:27:13Z")

</div>

Dear all,

I treid to make a timer that counts 100mSec. But I cannot make it work.

Can someone help me to make a timer? How can I use #asm code? And which timer can I use to count 100mSec?

Kind regards,

Willem-Jan

This is de code I made:

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
#use RCM43xx.LIB

unsigned int plus;

nodebug root interrupt void my\_isr0()  
{  
plus++;

}  
void main(void)  
{  
int lang; // variable for ending the program after 20 times

WrPortI(TCCR, &TBCRShadow, 0x09); // set timer on timer A1 and priority 1  
WrPortI(TCDHR, NULL, 0xC3); // set te count value on 49.999  
WrPortI(TCDLR, NULL, 0x4F);  
SetVectIntern(0x0B,my\_isr0);

WrPortI(TACSR, &TACSRShadow, 0x01); // enable timer  
WrPortI(TCCSR, &TCCSRShadow, 0x01); // enable timer

lang = 1;  
plus = 0;  
while(lang)  
{  
costate  
{  
waitfor(DelayMs(100));  
printf("%d  
", plus);  
lang++;  
}  
if (lang \>20) lang=0;

}  
}

#asm  
timerA\_isr::  
push af ; save used registers

ld a,0x00 ; set Timer A to pclk  
ioi ld (TAPR),a  
ld (TAPRShadow),a

ld a,0x01  
ioi ld a, (TACR) ; set Timer A on priotity 1  
ld (TACRShadow),a

ld a,0x73  
ioi ld a, (TAT1R) ; set Timer A1 (1/58MHz)\*116= 2usec  
ld (TAT1RShadow),a

pop af ; restore registers  
ipres  
ret  
#endasm

---

<div class="post-metadata">

**Author:** ![dwstojan](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@dwstojan](https://forums.digi.com/u/dwstojan)\
**Post date:** [July 8, 2008, 8:04pm UTC](https://forums.digi.com/t/timer-100msec/10121/2 "2008-07-08T20:04:03Z")

</div>

For one thing your interrupt handler should end with a reti (return from interrupt) instruction
