isaac12345
Member level 2
Hi guys,
I'm trying to use the PIC's timer0 to time a certain period of time. I'm using the CCS compiler, below's my code -
#include "16F877A.h"
int x=0;
#int_rtcc // Timer0 overflow interrupt
void isrtcc() // Interrupt service routine
{
++x;
switch(x)
{
case 0utput_high(PIN_D0);
break;
case 1utput_high(PIN_D1);
break;
case 2utput_high(PIN_D2);
break;
case 3utput_high(PIN_D3);
break;
case 4utput_high(PIN_D4);
break;
case 5utput_high(PIN_D5);
break;
case 6utput_high(PIN_D6);
break;
case 7utput_high(PIN_D7);
break;
}
}
void main() //********************************************
{
enable_interrupts(int_rtcc); // Enable named interrupt
enable_interrupts(global); // Enable all interrupts
ext_int_edge(H_TO_L); // Interrupt signal polarity
while(x<9) // Foreground loop
{
output_high(PIN_B1);
}
output_low(PIN_B1);
}
Problem is that the PIC never goes into the interrupt. It stays inside the while loop forever. My hunch is that the timer0 has not been enabled even though its interrupt is. If so, what's the command/function call to enable it?
Thanks!
I'm trying to use the PIC's timer0 to time a certain period of time. I'm using the CCS compiler, below's my code -
#include "16F877A.h"
int x=0;
#int_rtcc // Timer0 overflow interrupt
void isrtcc() // Interrupt service routine
{
++x;
switch(x)
{
case 0utput_high(PIN_D0);
break;
case 1utput_high(PIN_D1);
break;
case 2utput_high(PIN_D2);
break;
case 3utput_high(PIN_D3);
break;
case 4utput_high(PIN_D4);
break;
case 5utput_high(PIN_D5);
break;
case 6utput_high(PIN_D6);
break;
case 7utput_high(PIN_D7);
break;
}
}
void main() //********************************************
{
enable_interrupts(int_rtcc); // Enable named interrupt
enable_interrupts(global); // Enable all interrupts
ext_int_edge(H_TO_L); // Interrupt signal polarity
while(x<9) // Foreground loop
{
output_high(PIN_B1);
}
output_low(PIN_B1);
}
Problem is that the PIC never goes into the interrupt. It stays inside the while loop forever. My hunch is that the timer0 has not been enabled even though its interrupt is. If so, what's the command/function call to enable it?
Thanks!