hi,
Im new to the microcontroller world. Im using AT89S51 (8051) microcontroller to receive data from PC. I know that microcontroller can receive one byte per cycle from serial port. Does anyone have example code to receive two bytes at the same time and put the data in two separate variable.
thnx
Well if you have two bytes of RAM you put the first byte in one of them and the second byte in the other one. At some later time you can pick up the two pieces of data and treat them as a single number with a high byte and a low byte. It's the same for ANY 8-bit processor including the precious PIC and the equally precious AVR.
To receive two bytes at the same time you need two UARTs. Your uC (AT89S51) has only one hardware UART. You can make also a software UART but this code is much more complex.
On this page you have some simple code example for serial communication. 8051 serial code example
Please take some time and study it, check what instructions mean, how 8051 UART works and then you will understand how to write your own code.
If you are using assembly then its easy.Use any of R0 or R1 to point to a memory location and save the recieved data. Remember to increment them after every save.
To make things simple use R0 for the Low Order Byte and R1 for the High Order Byte.
It is quite common in the US, SiLabs and TI both use them in their products extensively. I've seen TI Audio chips that use 8051's in them and several of their system on a chip products use them. Right now I am working with an SoC from them that has an RF transceiver, USB 2.0 interface, and an 8051 with a bunch of peripherals (ADC, temp sensor, etc).
A lot of TI's stuff comes with a built in 8051 core uc. Nearly all their Zigbee Protocol devices.Although many would like it to be kept simple and the options open.
hi,
Im new to the microcontroller world. Im using AT89S51 (8051) microcontroller to receive data from PC. I know that microcontroller can receive one byte per cycle from serial port. Does anyone have example code to receive two bytes at the same time and put the data in two separate variable.
thnx
there is no way for that becasue 8951 or 8051 is a 8-bit processor u can't do that..refer a online book by mazidi......a famous author for micro-controller with c-language programming....jai ho
hi,
Im new to the microcontroller world. Im using AT89S51 (8051) microcontroller to receive data from PC. I know that microcontroller can receive one byte per cycle from serial port. Does anyone have example code to receive two bytes at the same time and put the data in two separate variable.
thnx
Hi,
you can not receive two bytes at the same time.
But you can write a program to receive two bytes after one another.
and then store them in two separate variable.