Can you be more specific please? When does the interrupt triggers?? What is the interrupt vector address? Thank you!coshkun said:If you have enabled its interrupt ,it jumps to the interrupt vector address when the overflow occurs.By that way you can run some code at specific time intervals.
If you enable a timer0 interrupt on overflow, then when timer0 overflows, your Program Counter will be set to 0x04, and the Interrupt Service Routine you wrote, will execute. Depending on what language you are using, you may have to take care of some registers when this happens.Can you be more specific please? When does the interrupt triggers?? What is the interrupt vector address? Thank you!
// Timer 0 for Scheduler
setup_timer_0 (RTCC_DIV_4);
set_timer0(0);
enable_interrupts(INT_TIMER0);
....
#INT_TIMER0
void Scheduler_Interrupt(void) // Internal Task Manager, Interrupt every 200 us
{
....
}
#pragma vector=PORT1_VECTOR // PORT_1 Interrupt Service Routine (ISR)
__interrupt void PORT1_ISR (void)
Yes, that is correct.This function void Scheduler_Interrupt(void) will be executed everytime timer 0 overflows?
Yes, you can use the prescaler and or an initial value in timer0. Be careful, though, as you cannot write directly to the high byte.Can I change the time timer 0 reaches it's maximum value?
That is correct.To interrupt on a change on pin I must use external interrupts (port B on PIC16F877)?
Yes, you are correct, the code starts executing where it left off. The way an interrupt works is that the Program Counter is pushed onto the stack when your interrupt executes, and then popped off the stack when the service routine exits. So the counter points to the last instruction before it entered the service routine.After this function is executed form where does my program starts executing again? Or it executes the code following the interrupt function?
Yes, you put your service routine there:does that code means the routine should be coded in there?
you put your statements where it is bolded.void PORT1_ISR (void) {
your actions go here;
}
Yes, but you most likely have control over which edge is used. The data sheet for your micro will tell you how to do this.about interrupt edge select, does the interrupt instantly triggered when an edge is detected?
No, the whole idea of using an interrupt is that you don't have to poll. Polling is a telephone which doesn't have a ringer. You pick up the reciever every few seconds to see if there is someone on the other end. A phone with a ringer has an interrupt. It uses a ring to interrupt you from what you are doing when someone calls you, so you don't have to keep checking. Hope this makes sense for you.or does it need to be polled?
case FrontZone :
set_adc_channel( FrontLeft );
delay_us( 12 );
__IR_Light[ FrontLeft ] = read_adc();
set_adc_channel( FrontRight );
delay_us( 12 );
__IR_Light[ FrontRight ] = read_adc();
set_adc_channel( Front );
delay_us( 12 );
__IR_Light[ Front ] = read_adc();
output_high( PIN_B2 );
delay_us( 300 );
__IR_Proximity[ Front ] = __IR_Light[ Front ] - read_adc();
set_adc_channel( FrontLeft );
delay_us( 12 );
__IR_Proximity[ FrontLeft ] = __IR_Light[ FrontLeft ] - read_adc();
set_adc_channel( FrontRight );
delay_us( 12 );
__IR_Proximity[ FrontRight ] = __IR_Light[ FrontRight ] - read_adc();
output_low( PIN_B2 );
break;
__IR_Proximity[ Front ] = __IR_Light[ Front ] - read_adc();
Code:
__IR_Proximity[ Front ] = __IR_Light[ Front ] - read_adc();
If __IR_Light[ Front ] is the value red from ADC channel, read_adc() that is, won't the result be 0 (zero)? Then won't the the value printed on the hyperterminal be 0???
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?