Actually I want to transmit 3 bits serially using AT89C51 micro-controller.
I have written the code in ".c" file, using c programming trying to transmit the bits serially using SBUF register.
As the SBUF register is the single register available in serial programming of 89C51, it is not updating its value. The bit which is first transmitted is only repeated in the next 2 bits, it is not being updated and then transmitted.
So I want guidance regarding sending 3 bits(number / integer) using serial communication( with SBUF register).
Following is the code I have written,
#include<reg51.h>
void decimal(); void MSB(); void MIDDLE(); void LSB();
void main() { while(1) { decimal();
MSB();
MIDDLE();
LSB();
}
void decimal() { unsigned char x,bin,d1,d2,d3;
bin = Data_Bus; x = bin /10; d1 = bin %10; d2 = x %10; d3 = x/10;
void MSB() { unsigned char d1,a; TMOD = 0X20; TH1 = 0XFD; SCON = 0X50; TR1 = 1; a = d1 +0x30; SBUF = a; while(TI==0); TI = 0;
void MIDDLE() { unsigned char d2,b; TMOD = 0X20; TH1 = 0XFD; SCON = 0X50; TR1 = 1; SBUF = 0x00; b= d2 + 0x30; SBUF = b; while(TI==0); TI = 0; }
void LSB() { unsigned char d3,c; TMOD = 0X20; TH1 = 0XFD; SCON = 0X50; TR1 = 1; SBUF = 0x00; c= d3 + 0x30; SBUF = c; while(TI==0); TI = 0; }
Best if you start again. Code is total nonsense.
Code is total nonsense agreed. you set the parameters 3 tines (nonsense) and do not test TI (nonsense) plus more, but that should be a start
and this time, pay attention to the instructions for properly posting source code - look at this picture to help you: www.danlhenry.com/.../keil_code.png
See also: http://www.keil.com/books/8051books.asp
And: http://www.keil.com/appnotes/list/c51.htm
And: http://www.keil.com/download/list/c51.htm
And: www.microchip.com/.../AT89C51RB2 - see the 'Documents' tab
etc, etc, ...
It's not like the 8051 is a new chip with a shortage of reference materials ...