8051,not able to receive from serial port.......Plz Help,,,,

hi ;

This is sulabh,i am programming my controller 89s52, for recieving and trasmitting from serial port .I m using embedded C in keil UV2.

It is trasmitting properly but while reception it is not raising the RI flag...(i suspect) , in main loop of my programme i m checking for : _____________________________________________________________ while(1) { if(trigger==1) // Externel input for trigger { Tx_char(); }

if(RI==1 ) { Rx_Char(); } }

_________________________________________________________________

In main programme i m giving

TMOD=0x22; SCON=0x50; _________________________________________________________________

In DEbugger window it is working fine,in hardware it is showing (ON Osciloscop)that whenever i m giving trigger it is transmitting through pin 11, by the same time i m receiving the txmitted stream in another

89s52 and on that Rx pin it is showing that same data has reached to 89s52(second), but it is not receiving and not going in rx_char() subroutine.

I am stuck here Plz help....

Sulabh

" snipped-for-privacy@yahoo.com"

Reply to
sulabhmatele
Loading thread data ...

embedded C in keil UV2.

raising the RI flag...(i suspect)

Hi Sulabh, Not familiar with your chip, but here's a couple ideas to check: I assume your serial routines are polled, and not interrupt driven (??)

In either case: The RI interrupt flag might need to be cleared manually after each character. I would start there. Simply fetching the character from the receive buffer may not clear this flag, and then all subsequent received characters get "stuck", and eventually get overwritten in the buffer.

Next (but not as likely to be the problem?), on the Dallas Semi DS87C530 chip for example, there is a bit tucked away in one of the Special Function Registers (SRF) to enable reception on the serial port - though there is no corresponding bit for transmit.

I think I spent an entire day chasing that one!

Anyway, like I said, I don't recall the Atmel chips having Serial Receive Enables tucked away like that, but it might be worth a look in the Datasheet? Good luck.

-mpm

Reply to
mpm

schreef in bericht news: snipped-for-privacy@n76g2000hsh.googlegroups.com...

Did you clear RI before you start the receiver? It's not enough to clear it in the main program. You have to make sure it is cleared before you start receiving and you have to clear it again after reading SBUF.

petrus bitbyter

Reply to
petrus bitbyter

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.