View previous topic :: View next topic |
Author |
Message |
kkatesuda
Joined: 09 Sep 2006 Posts: 8
|
Interrupt in 18f4431 not work |
Posted: Sat Sep 09, 2006 9:14 am |
|
|
I use 18f4431 and interrupt not work. I already initial interrupt function
enable_interrupts(GLOBAL); //enable global interrupts
enable_interrupts(INT_RDA); //enable Serial Interrupts
and I already make Serial Interrupt function.
#INT_RDA
RDA_isr(){
}
But it not work, please advice me
katesuda |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Sep 09, 2006 12:10 pm |
|
|
Here is a very simple test program for #int_rda on an 18F4431.
I tested this with PCH vs. 3.249 on a PicDem2-Plus board. It works.
When you type a character, it will get sent to the PIC, and the PIC
will send back the next higher character. If you type 'A', you will
get 'B', etc. This is done in case you have "local echo" enabled
on your terminal program, and you didn't know it. If you type 'A'
and then get 'B', then you know the program and your hardware
are working correctly.
Code: |
#include <18F4431.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#int_rda
void rda_isr(void)
{
char c;
c = getc();
putc(c + 1);
}
//======================================
void main()
{
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
while(1);
} |
|
|
|
kkatesuda
Joined: 09 Sep 2006 Posts: 8
|
|
Posted: Sat Sep 09, 2006 8:11 pm |
|
|
Thank you for PCM programmer after I burn use your code to my PIC Chip. Interrupt not work again. I don't know why. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Sep 09, 2006 10:35 pm |
|
|
Here is a version that doesn't use interrupts. Try it.
Code: | #include <18F4431.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//===================================
void main()
{
int8 c;
printf("Start: ");
while(1)
{
c = getc();
putc(c +1);
}
} |
If this code doesn't work, then check your hardware. |
|
|
kkatesuda
Joined: 09 Sep 2006 Posts: 8
|
|
Posted: Sat Sep 09, 2006 11:46 pm |
|
|
Very Thank for PCM programmer
I found the problem it from 18f4431 it not receive any information. I not have any debugger, very thank for your helpful. Now I use other cpu for temperary 18f4550 it work.
Katesuda |
|
|
|