|
|
View previous topic :: View next topic |
Author |
Message |
picj1984
Joined: 01 Mar 2010 Posts: 73
|
[SOLVED] #INT_RDA not working on pic16F1509 |
Posted: Thu Oct 19, 2017 5:29 pm |
|
|
Hello,
I'm having trouble generating an interrupt and reading serial data on a pic16f1509. I've got a scope on B5 and I can see the data coming in. I've also used essentially the same code on a pic16f1527 with no issues, works beautifully. I'm wondering if there's something silly I'm missing here. My code is below:
Code: |
#include <16f1509.h>
#fuses NOWDT, NOLVP, PROTECT
#device ICD=TRUE
#use delay(clock=16000000, int)
#use rs232(baud=31250,parity=N,stop=1,xmit=PIN_B7,rcv=PIN_B5,bits=8, ERRORS)
unsigned char state = 1;
#INT_RDA
void RDA_isr()
{
state = getc();
}
void main ()
{
enable_interrupts(GLOBAL);
enable_interrupts(INT_RDA);
while(1)
{
}
}
|
DETAILS:
PCM Compiler V4.140
PIC161509
Debug Mode
Target Voltage is 5V
Osc Speed 16MHz internal
Last edited by picj1984 on Mon Oct 23, 2017 2:03 pm; edited 1 time in total |
|
|
picj1984
Joined: 01 Mar 2010 Posts: 73
|
|
Posted: Thu Oct 19, 2017 6:21 pm |
|
|
I thought I would try the kbhit() function and that works just fine. So it seems the interrupt is just not firing.... I'd really prefer to use the interrupt here for when the code gets more complex. Working code is below... any ideas??
Code: |
#include <16f1509.h>
#fuses NOWDT, NOLVP, PROTECT
#device ICD=TRUE
#use delay(clock=16000000, int)
#use rs232(baud=31250,parity=N,stop=1,xmit=PIN_B7,rcv=PIN_B5,bits=8, ERRORS)
unsigned char state = 1;
void main ()
{
while(1)
{
if(kbhit())
{
state = getc();
}
}
}
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9255 Location: Greensville,Ontario
|
|
Posted: Thu Oct 19, 2017 7:55 pm |
|
|
this...
Debug Mode
... is a huge red flag for me.
Typically 'debug' adds a LOT of code so your program won't work in the 'real world'.
If using MPLAb you need to change the 'build configuration' to 'release', then recompile,burn the PIC and test....
Since I never use the ICD , I don't know what it 'adds' but presumably it'll alter your code as well....
I've always cut/compiled/test in real world...
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19569
|
|
Posted: Fri Oct 20, 2017 1:06 am |
|
|
This post:
<http://www.ccsinfo.com/forum/viewtopic.php?t=51711&highlight=pic16f1509>
Has a user with the same chip running INT_RDA basically OK (so it is tripping OK for him).
I would suggest though always using the UART name, rather than the pins (this ensures the hardware UART is selected). So:
#use rs232(UART1, baud=31250,parity=N,stop=1,bits=8, ERRORS)
This is equivalent to having both the pins and 'FORCE_HW' specified.
You have the external debug header?.
Have you tried the same basic test (just flash an LED when a character is seen), without the debugger?. |
|
|
picj1984
Joined: 01 Mar 2010 Posts: 73
|
|
Posted: Mon Oct 23, 2017 1:37 pm |
|
|
Ttelmah wrote: | This post:
<http://www.ccsinfo.com/forum/viewtopic.php?t=51711&highlight=pic16f1509>
Has a user with the same chip running INT_RDA basically OK (so it is tripping OK for him).
I would suggest though always using the UART name, rather than the pins (this ensures the hardware UART is selected). So:
#use rs232(UART1, baud=31250,parity=N,stop=1,bits=8, ERRORS)
This is equivalent to having both the pins and 'FORCE_HW' specified.
You have the external debug header?.
Have you tried the same basic test (just flash an LED when a character is seen), without the debugger?. |
You are incredible! I just put in #use rs232(UART1, baud=31250,parity=N,stop=1,bits=8, ERRORS) and it solved it!!
still debugging away, too!
Fantastic, thank you!! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|