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

UART RX Problem

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



Joined: 23 Dec 2008
Posts: 83

View user's profile Send private message

UART RX Problem
PostPosted: Fri Apr 01, 2011 8:40 pm     Reply with quote

Dear All,
I am having a problem with UART. I am using 18F4620 clocked at 4 Mhz. uc hangs when it receives serial data sent from another uc. I also used getc, but still I don't have any progress. I have completely checked the hardware on both sides. I can read the serial data in PC sent from the other TX controller. Likewise my receiving controller reads the data when sent from the PC. But if I connect both controllers, it hangs and sometimes it receives junk characters. Please advise.
Code:

#fuses XT,PROTECT,PUT,NOBROWNOUT,NOLVP,NOWDT
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,ERRORS)

#INT_RDA
void serial_reciv_int(void)
{

 clear_line(2);
 lcd_gotoxy(1,2);

   for(i=0;i<=8;i++)
   {
   lcd_putc(rxmessage[i]);
   }

}
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Apr 01, 2011 11:57 pm     Reply with quote

That's your whole program?

How can that compile with no main()??
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
arunkish



Joined: 23 Dec 2008
Posts: 83

View user's profile Send private message

PostPosted: Sat Apr 02, 2011 2:22 am     Reply with quote

That's not my whole program. I have just given you the section of code.
Ttelmah



Joined: 11 Mar 2010
Posts: 19343

View user's profile Send private message

PostPosted: Sat Apr 02, 2011 2:35 am     Reply with quote

Key thing that is wrong, is what int_rda does....

You need to understand what INT_RDA implies. It triggers when _one_ character is ready to be read from the serial. The handler need to do just one thing. Read this character. This is _all_ it should do, and what it _must_ do.
Your INT_RDA, does not read the character. Unless it does, the code will hang for ever, looping back to the interrupt as soon as you exit the interrupt.
Instead your INT_RDA code, writing 8 characters to the LCD (and clearing a screen line, which takes even longer).
Look at the EX_SISR. c example, which shows what an INT_RDA, _should_ do. save the characters, so that the external code can use them when _it_ is ready to.

Best Wishes
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