View previous topic :: View next topic |
Author |
Message |
iKevin
Joined: 27 Mar 2008 Posts: 9
|
#int_RDA never fires (18F4520) compiler version = PCH 4.094 |
Posted: Sun Feb 21, 2010 8:06 pm |
|
|
Hi,
I have an interrupt for RS232 (#int_RDA), but it never fires when it receives data.
So I checked the include file 18f4520.c and found:
Code: | #define INT_RDA 0x9D20 |
I checked the datasheet and the SPFs for RDA is bit 5 of PIR1 (RCIF)
Can I do the following because the RDA interrupt address might be wrong?
Code: |
#define PIR1 0xF9E
#bit RCIF = PIR1.5
#define int_UART_RX RCIF
#int_UART_RX
void uart_rx_isr(void)
{
//blah blah
}
|
Here is the completed program:
Code: |
#include <18f4520.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT
#use delay (clock=20000000)
#define tx_pin PIN_C6
#define rx_pin PIN_C7
#use rs232(baud=2400, xmit=tx_pin, rcv=rx_pin, stream=PC, ERRORS)
#int_RDA
void RDA_isr(void)
{
printf("RDA fires\n\r");
}
void main()
{
}
|
My compiler version is PCH 4.094u
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 21, 2010 8:46 pm |
|
|
You need to call the enable_interrupts() routine for both INT_RDA and
GLOBAL interrupts (2 lines of code). |
|
![](templates/subSilver/images/spacer.gif) |
iKevin
Joined: 27 Mar 2008 Posts: 9
|
|
Posted: Sun Feb 21, 2010 9:06 pm |
|
|
I put those enables in and it works, thanks a lot buddy.
Code: | #include <18f4520.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT
#use delay (clock=20000000)
#define tx_pin PIN_C6
#define rx_pin PIN_C7
#use rs232(baud=2400, xmit=tx_pin, rcv=rx_pin, stream=PC, ERRORS)
#int_RDA
void RDA_isr(void)
{
printf("RDA fires\n\r");
}
void main()
{
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
|