I downloaded AT89C51ED2 UART source code from ATMEL web. when I connected from PC COM1 to AT89C51ED2 and sended a byte data, it sended a wrong byte data back. Have some solutions about this @@?
check the connections to your MAX232(equivalent) and the signals there with a scope. Also verify the baudrate both ways. Erik
I am sure the connections is right. because it is a development kit board. The board use the same port which is RS232 DB9 connector to download the hex file(use FLIP). The C source file was downloaded from ATMEL. I don't modify it. The SPI example(ATMEL) is work, and the UART example cant...>_< I had search the internet, someone says that maybe the UART use 9bit or else. It makes the PC COM1 can't read correct. PS. I dont have oscilloscope, I just a student. >_<
what baudrate, how is it set? Erik
you can find the source code in following link http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3420 I use C51 UART Mode1 Timer1 (24 KB, updated 06/04) 9600bps Regard.
I use C51 UART Mode1 Timer1 (24 KB, updated 06/04) 9600bps what are the SFRs (SCON, TCON, TMOD, TH1, TL1, IE set to) Erik
hi erik the same with the source code. SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */ TMOD = TMOD | 0x20 ; /* Timer 1 in mode 2 */ TH1 = 0xFD; /* 9600 Bds at 11.059MHz */ TL1 = 0xFD; /* 9600 Bds at 11.059MHz */ ES = 1; /* Enable serial interrupt */ EA = 1; /* Enable global interrupt */ TR1 = 1; /* Timer 1 run */ I didn't modify it. Regard, Yuhung
PCON? what are you using in the other end
PCON? It is not setting in source code. Should I set it a value? the other end.... I use PC COM1 with Windows hyperTerminal (C:\Program Files\Windows NT\hypertrm.exe) the setting is 9600 / 8 / N / 1 / N(flow control?) PS. I use the windowsXP which is Non-English version. so, I am not sure it is "flow control". Regasrd.
I am try to send data with Hyper Ternimal 9600/8/n/1/n Send->"abcdefghijklmnopqrestuvwxyz" Receive->"yz{|}~hijklmnoxyz}{|}~xyz"
"I am try to send data with Hyper Ternimal 9600/8/n/1/n Send->"abcdefghijklmnopqrestuvwxyz" Receive->"yz{|}~hijklmnoxyz}{|}~xyz"z"" Looks like your baudrate is slightly out. Are you using a 12MHz crystal? The reload value in the code you are using is for an 11.0592MHz crystal. There is a baudrate calculator on this website that will let you calculate the correct values. Alternatively, why don't you use the internal baudrate generator on the ED2?
hi Stefan Duncanson I'm using 11.0592MHz crystal. and ATMEL's web have following codes. 1.C51 UART Mode1 Internal Baud Rate Generator (23 KB, updated 06/04) 2.C51 UART Mode1 Timer1 (24 KB, updated 06/04) 3.C51 UART Mode1 Timer2 (22 KB, updated 06/04) they can't send data back correctly. >_< I tried it, but cant work.
here has some talk about this question. http://www.grote.net/bascom/frm22321.html but im not sure how to make it success in hyper terminal.
"I'm using 11.0592MHz crystal" Maybe hyperterminal is your problem - try using a different terminal emulator such as TeraTerm. "they can't send data back correctly." Do you get the same result with all three programs? Are you typing the characters one by one into hyperterminal, and if not, what happens if you do?
i download TeraTerm and test it. the 3 examples are same result. send=>"1234567890" receive=>"9:;<=>?898" PS. using 115200 in "3.C51 UART Mode1 Timer2" software setting it that send a byte one by one. (HyperTerminal and TeraTerm) I dont know where the problem is.....>_< PC COM1<-->HIN232<-->AT89C51ED2 Source code => from ATMEL
I use C51 UART Mode1 Timer1 (24 KB, updated 06/04) 9600bps later PS. using 115200 in "3.C51 UART Mode1 Timer2" which is it? software setting it that send a byte one by one. thus you have changed something. if you are running 115k you need be careful that the processing is not too slow Erik