View previous topic :: View next topic |
Author |
Message |
jjm1964
Joined: 10 Mar 2005 Posts: 6
|
#int_rda not working? |
Posted: Thu Mar 10, 2005 1:39 pm |
|
|
Hello,
I'm trying to interrupt on RS232 data available (I don't care about outputting to the port for now). Here's what I tried that isn't working:
===============================================
#if defined(__PCM__)
#include <16F648A.h>
#fuses INTRC_IO,NOWDT,PROTECT,NOLVP,NOMCLR,PUT,BROWNOUT,NOCPD
#use delay(clock=16000000)
#use rs232( baud=9600,xmit=PIN_B2, rcv=PIN_B1, parity=N, bits=8)
#endif
#case
#define TRIS_A 0x02
#define TRIS_B 0x34
void Init()
{
set_tris_a( TRIS_A );
set_tris_b( TRIS_B );
output_a(0x00);
output_b(0x00);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
}
void main()
{
Init();
while( 1 )
; // do nothing
}
#int_rda
void Handle_RDA()
{
BYTE btRead;
btRead = getch();
}
===============================================
I know there is data coming across the port at 9600 N 8 1 as I am moniitoring with my PC. Any ideas? I have the latest compiler update.
Also, is it true that I cannot run at 4Mhz and receive at 9600?
Thanks |
|
|
jjm1964
Joined: 10 Mar 2005 Posts: 6
|
|
Posted: Thu Mar 10, 2005 1:40 pm |
|
|
What is happening is that it never interrupts. Thanks |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Thu Mar 10, 2005 1:45 pm |
|
|
How do you know it never interrupts? It will interrupt, but your code won't do anything to let you know that it did interrupt.
If you toggle an output line inside your RDA interrupt, you'll see that it is properly receiving.
I'm also assuming that you have the pins in your #use rs232 statement correct - that they're set up to use the USART. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 10, 2005 1:56 pm |
|
|
Quote: | #include <16F648A.h>
#fuses INTRC_IO,NOWDT,PROTECT,NOLVP,NOMCLR,PUT,BROWNOUT,NOCPD
#use delay(clock=16000000) |
Immediate problem: The internal oscillator is 4 MHz on this chip.
You've got your #use delay() statement set for 16 MHz. That's not right. |
|
|
jjm1964
Joined: 10 Mar 2005 Posts: 6
|
|
Posted: Thu Mar 10, 2005 1:58 pm |
|
|
I put a breakpoint in the interrupt and it never breaks. I know there is data coming because if I use the "non-interrupt" method, I get data. "non-interrupt" being this
if ( kbhit() )
{
c = getc();
// do something with c
}
which works just fine.
Thanks |
|
|
jjm1964
Joined: 10 Mar 2005 Posts: 6
|
|
Posted: Thu Mar 10, 2005 2:06 pm |
|
|
Sorry,
I do have the osc set at 4000000, still doesn't work.
Thanks |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Mar 10, 2005 2:07 pm |
|
|
if B2 is transmit and B1 is receive, why do you have tris_b set to 0x34? That would make B2 and input and B1 an output. |
|
|
jjm1964
Joined: 10 Mar 2005 Posts: 6
|
|
Posted: Thu Mar 10, 2005 3:22 pm |
|
|
Well, not only that but the Max485e is wired backwards. Interesting.
Thanks |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Mar 10, 2005 3:24 pm |
|
|
jjm1964 wrote: | Well, not only that but the Max485e is wired backwards. Interesting.
Thanks |
so I guess this was a lie?
Quote: | I put a breakpoint in the interrupt and it never breaks. I know there is data coming because if I use the "non-interrupt" method, I get data. "non-interrupt" being this
if ( kbhit() )
{
c = getc();
// do something with c
}
|
|
|
|
|