electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

to read from sbuf in 8051


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> to read from sbuf in 8051
Author Message
fatima_just



Joined: 13 Sep 2008
Posts: 19


Post01 Dec 2008 18:55   

sbuf in 8051


please help me .

I use uvision Kiel software to program 8051 using C language like this :
unsigned char SerialRecvChar()
{
//initialization
TMOD = 0x20; // timer 1 (8 bit auto-reloed)
TH1 = 0xFD; //to obtain 9600 baud rate
TR1 = 1; //start timer
SCON = 0x50;
//IE= 0x90;
P1= 0x00;

unsigned char i;
while(!RI); //waits till a byte is recieved
RI = 0;
i = SBUF ; //must get SBUF value
return SBUF;
}


but when I run the code to show (i = Sbuf ) then (i) not get the value from SBUF )
Back to top
Google
AdSense
Google Adsense




Post01 Dec 2008 18:55   

Ads




Back to top
besthabit



Joined: 07 Oct 2007
Posts: 27
Location: Islamabad


Post26 Jan 2009 5:56   

sbuf register in 8051


simplest example (read & write from RS232 using Hyperterminal baud rate 1200) 8051

Get the value in main

char getCharacter (void)
{
char chr; // variable to hold the new character
while (RI != 1) {;}
chr = SBUF;
RI = 0;
return(chr);
}


void send (char a)
{
SBUF = a;
while (TI != 1);
TI=0;
}




void main (void)
{




SCON = 0x50; // mode 1, 8-bit uart, enable receiver
TMOD = 0x20; // timer 1, mode 2, 8-bit reload
TH1 = 0XE6; // for 9600 baud rate 0XFD
TL1 = 0XE6;
TR1 = 1;
TI = 0;
SBUF =0;


while (1)
{
your code



}//end of while
}//end of main
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> to read from sbuf in 8051
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
SBUF in 8051 (3)
How to Create UART with Software (not used SBUF) on 8051 (7)
how can I read from an SD Card with an 8051? (4)
How to read signals in 8051? (6)
can 8051 microcontroller read in text file? (1)
question on 8051 - code to read and write into eeprom (4)
8051 Interface with Compact Flash Card to Read and Write Dat (1)
8052 SI SBUF Write, function like kbhit to work with K*eil? (3)
read asm from hex (6)
read from gsm modem (5)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS