Timer 100mSec

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

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