|
|
View previous topic :: View next topic |
Author |
Message |
arunkish
Joined: 23 Dec 2008 Posts: 83
|
UART RX Problem |
Posted: Fri Apr 01, 2011 8:40 pm |
|
|
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: 1615 Location: Central Illinois, USA
|
|
Posted: Fri Apr 01, 2011 11:57 pm |
|
|
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
|
|
Posted: Sat Apr 02, 2011 2:22 am |
|
|
That's not my whole program. I have just given you the section of code. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Sat Apr 02, 2011 2:35 am |
|
|
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 |
|
|
|
|
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
|