CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

#int_rda not working?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jjm1964



Joined: 10 Mar 2005
Posts: 6

View user's profile Send private message

#int_rda not working?
PostPosted: Thu Mar 10, 2005 1:39 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 10, 2005 1:40 pm     Reply with quote

What is happening is that it never interrupts. Thanks
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Thu Mar 10, 2005 1:45 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 10, 2005 1:56 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 10, 2005 1:58 pm     Reply with 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
}

which works just fine.
Thanks
jjm1964



Joined: 10 Mar 2005
Posts: 6

View user's profile Send private message

PostPosted: Thu Mar 10, 2005 2:06 pm     Reply with quote

Sorry,
I do have the osc set at 4000000, still doesn't work.
Thanks
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Mar 10, 2005 2:07 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 10, 2005 3:22 pm     Reply with quote

Well, not only that but the Max485e is wired backwards. Interesting.
Thanks
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Mar 10, 2005 3:24 pm     Reply with quote

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
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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