hi everyone i wrote this program expecting a increment in the port c for every second but something is wrong that i get rb6 and rb7 la 2.39 to 2.71
other rb0-rb5 2.55 v somebody please help
code is
#include <htc.h>
/*
* code for using timer0 on a 16F877A
* Just sets up a 1 micro-second interrupt and increments a variable
*/
/*
* Calculate preload value for one second timer
*/
#define PERIOD 1000000 // period in uS - one second here
#define XTAL 10000000 // crystal frequency - 10MHz
#define IPERIOD (10*10000000/XTAL) // Period of instruction clock in uSeconds
#define SCALE 256 // Timer 0 prescaler
#define T0_TICKS 256 // Number of counts for interrupt
#define TICK_PERIOD (SCALE * IPERIOD) // Period (uSec) of one increment of timer 0
#define RELOADS ((PERIOD/T0_TICKS)/TICK_PERIOD)
__CONFIG(LVPDIS & BORDIS & PWRTEN & WDTDIS & HS);
unsigned long seconds; // second count
near char reload = 0;
/* service routine for timer 0 interrupt */
void interrupt
timer0_isr(void)
{
if(reload == 0){
// effect a change on PORTC whenever our desired period is reached.
reload = RELOADS + 1;
seconds++;
PORTB++; // effect a change on PORTB
}
reload--;
T0IF = 0;
}
main()
{
// initialize timer 0;
OPTION = 0b0000; // prescale by 2
T0CS = 0; // select internal clock
T0IE = 1; // enable timer interrupt
GIE = 1; // enable global interrupts
TRISB = 0; // output changes on LED
for(;
continue; // let interrupt do its job
}