vinctal
Newbie level 4
Hi, I am new in Microcontroller programming. I wish to investigate the duration taken to execute Timer 0 Interrupt.
Port RB1 is set to high upon entering interrupt service routine and Port RB0 is being toggled every time when Timer 0 Interrupt occurs. So RB0 output is being monitored to check the interval between Timer 0 Interrupt occurs whilst RB1 is being monitored to check the duration taken to execute the interrupt service routine.
The Interrupt Time is set to 55.6 us. However the simulation results in proteus show that the Interrupt time (RB0) is about 60 us...
Can anyone help to explain ?
Thanks
//--------------------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------------------
Port RB1 is set to high upon entering interrupt service routine and Port RB0 is being toggled every time when Timer 0 Interrupt occurs. So RB0 output is being monitored to check the interval between Timer 0 Interrupt occurs whilst RB1 is being monitored to check the duration taken to execute the interrupt service routine.
The Interrupt Time is set to 55.6 us. However the simulation results in proteus show that the Interrupt time (RB0) is about 60 us...
Can anyone help to explain ?
Thanks
//--------------------------------------------------------------------------------------------------------------------------------------------------
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 #include <htc.h> __CONFIG (FOSC_HS & WDTE_OFF & PWRTE_OFF & BOREN_OFF & LVP_OFF); #define _XTAL_FREQ 20000000 void interrupt ISR( ) { RB0 = !RB0; RB1 = 1; if (TMR0IF) //Timer 0 interrupt, occurs when 'Timer 0 counter' = TMR0 { TMR0IF = 0; //Clear interrupt flag bit TMR0=117; } RB1 = 0; } void main(void) { TRISA=0b00000000; PORTA=0b00000000; TRISB=0b00000000; PORTB=0b00000000; TRISC=0b00000000; PORTC=0b00000000; TRISD=0b00000000; PORTD=0b00000000; //TIMER 0 INTIALIIZE //Prescaler 1:2; TMR0 Preload = 117; Actual Interrupt Time : 55.6 us OPTION_REG = 0x80; TMR0 = 117; INTCON = 0xA0; while(1) { } }
//--------------------------------------------------------------------------------------------------------------------------------------------------
Last edited by a moderator: