2006-05-25 01:59 PM
timer interrupt routine problem COSMIC compiler
2006-05-03 08:03 PM
hello
i wrote a program that operate the timer as a counter. in intetion to create an interrupt. there are 3 problems: 1) the TCHR and TCLR are not going up only the TACR 2) the TOF register never occure never set to 1. 3) I alwys enter the interrupt routine and I can not go out from it. My program is: #include #define output 1 #define input 0 #define EnableInterrupts _asm(''RIM'') #define DisableInterrupts _asm(''SIM'') void main() { EnableInterrupts; TCR1=0b00100000; //configure the counter TCR2=0b00000100; TCSR=0b00000100; TCLR=0; //restat the counter to 650000 //TCSR=0b00000000; while(1) { } } and th INPERRUPT: extern void _stext(); /* startup routine */ //extern unsigned char ohad; @interrupt void INT_Timer(void) { //return; char t2=9; t2=10; t2=11; } /* Interrupt vector table, to be linked at the address 0xFFE0 (in ROM) */ void (* const _vectab[])() = { INT_Timer, /* 0xFFE0 */ INT_Timer, /* 0xFFE2 */ INT_Timer, /* 0xFFE4 */ INT_Timer, /* 0xFFE6 */ INT_Timer, /* 0xFFE8 */ INT_Timer, /* 0xFFEA */ INT_Timer, /* 0xFFEC */ INT_Timer, /* 0xFFEE */ INT_Timer, /* 0xFFF0 */ INT_Timer, /* 0xFFF2 */ INT_Timer, /* 0xFFF4 */ INT_Timer, /* 0xFFF6 */ INT_Timer, /* 0xFFF8 */ INT_Timer, /* 0xFFFA */ INT_Timer, /* Trap vector */ _stext, /* Reset Vector */ };2006-05-03 09:26 PM
2006-05-03 10:11 PM
Hello Luca
Can u tell me how do i clear the Interrupt Flag?? after I get in to interrupt routine i have added: @interrupt void TIMER_int (void) { char ohad1=0; ohad1=1l; ohad1=12; ohad1=TCSR; TCLR=0; } when I look into the VIEW-->Peripheral Register I can not see the TOF flag at all. so can you tell how do i get out from thsu interrupt?? I suspect that the TOF is still set or i did not put IRET instruction thanks ohad2006-05-25 01:59 PM
I think you should not put all interrupt to INT_Timer,maybe you can write one interrupt routine for every interrupt. then you will find where work wrong.
do you think so. regards.