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 support@ccsinfo.com

Serial port woes

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







Serial port woes
PostPosted: Wed Oct 04, 2006 7:51 pm     Reply with quote

I'm working on an 18f6722, and I'm trying to read from the serial ports. I can read from the primary serial port with no problem, but I'm only able to read at most 3 characters from the secondary serial port. I'm hoping that someone can shed some light on why. (I know that there is a 3 char buffer, but that still doesn't explain why I can't get more than that.)

Here is the code that I'm using. Like I said, for PORT1, this works with no problem, but on PORT2, I can only get 3 characters. Suggestions?

#include <18f6722.h>
#device ICD=TRUE
#device ADC=10 // 10 bit a/d conversion
#fuses HS, NOLVP, NOWDT, PUT
#use delay (clock=4000000)

#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7, stream=PORT1)
#use rs232 (baud=4800, xmit=PIN_G1, rcv=PIN_G2, stream=PORT2)

char buf1[120] = "";
char buf2[120] = "";
int8 buf1_idx = 0;
int8 buf2_idx = 0;

#int_rda
com_isr()
{
if( kbhit(PORT1) )
{
buf1[buf1_idx++] = fgetc(PORT1);
buf1_idx%=120;
}
if( kbhit(PORT2) )
{
buf2[buf2_idx++] = fgetc(PORT2);
buf2_idx%=120;
}
}

void main(void)
{
enable_interrupts(int_rda);
enable_interrupts(global);
while(TRUE)
{
if(buf2_idx > 5 )
{
led_on();
}
}
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Oct 04, 2006 8:24 pm     Reply with quote

int_rda is the handler for the fist serial port. You need int_rda2 for the second serial port.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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