Please tell me how to use Uart2 to exchange data? I Use C51 development and ST uPSD3234A chip.
Alan, Thank you first. putchar()is a function that put the char to a Uart supported by the development. void initialize_system (void) { PCON &= 0x7F; SCON = 0x50; TMOD |= 0x20; TCON = 0x40; TH1 = 0xFD; TR1 = 1; TI = 1; } The above are codes which already set Uart0 to work successfully. I just to change codes to set Uart1 to work but no use. I think maybe the below will solve the problem. Something wrong with my codes. System maybe not support the P1=Uart1 which stated by uPSD3200 FAMILY. There are so many chips which set with a little difference so have not a standard. I now to study about interrupt of system and try again. Thanks for your suggestion.
There is one thing that I have thought to be quite beneficial when it comes to code debugging, that is, write your own serial receive/transmit functions instead of using the provided printf() or putchar(), etc., such that you can easily set breakpoints, poke bits and bytes. Here is what I would do,
/*Call this function when you want to transmit*/ void TxSData() { pTxBuffer=uTxBuffer; uTxByteCount=PACKET_LENGTH; TI1=1; } /*UART1 ISR*/ void Serial1() interrupt y [using z] { if(RI1) { RI1=0; . //May need ptr sanity check *pRxBuffer++=SBUF1; . } if(TI1) { TI1=0; if(uTxByteCount--) SBUF1=*pTxBuffer++; } }
Alan, Thanks for your suggestion. I found the key to my problem. There are no fault with my code. But the hardware didn't set the RI2 and TI2 with 1 after receive and transmit a char. So the chip are waiting for set. So it had no result from uart2. Do you have some suggestion about this question. Thank you again.
Do you have some suggestion about this question? I am not sure what this question is. Apparently you have already concluded that your problem was due to a hardware failure. In that case, I will be very interested to know your diagnostic procedure.
For example:
for(i=48;i<58;i++) putchar(i);
Here is what I would do:
TI2=0; //Just in case TI2 has been set.. for (i=48; i<58; i++) { SBUF2=i; //Not sure if SBUF2 is the right //symbol name. Could be S2BUF? while(!TI2) //TI2 will be set by hardware { //upon completion of one byte } TI2=0; }
I tried, but not successful. If you set TI2 to 1 by software. It passed. So sth wrong with the hardware. I believe it. Thank you for your help.
By the way, Which country are you in?