PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 05, 2006 8:34 pm |
|
|
My first comment is that you have way too much code to test this problem.
Notice how small my program is. Smaller is better, when investigating
a problem.
The following program works OK on the PicDem2-Plus board.
It blinks LED "RB0" at a rate of 2 seconds on, and then 2 seconds off.
This is correct, because with a 32.768 KHz crystal, it will take 2 seconds
to make Timer1 count from 0x0000 to 0xFFFF and then overflow to
0x0000 to create the interrupt.
Also make sure that you have jumper J6 installed. This jumper
enables the LEDs.
Code: | #include <18F452.H>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay (clock=4000000)
#int_timer1
void timer1_isr(void)
{
output_toggle(PIN_B0);
}
//==================================
void main()
{
output_low(PIN_B0);
setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1 | T1_CLK_OUT);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
while(1);
} |
|
|