Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to use 8051 serial mode control?

Status
Not open for further replies.

bill_test36

Junior Member level 3
Joined
May 20, 2003
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Taiwan
Activity points
174
:( I USER 8051 SERIAL MODE transmission DATA but no success in mode 2 and mode 3 .
how to 8051 SERIAL MODE control??? :cry:
 

8051 serial

Hi bill_test36

Can you post your code here ?
 

serial mode 2 in 8051

Hello there,

Try this link:
**broken link removed**

They have an easy to understand explanation on serial mode programming. I used to implement these modes without any problems.
Ask again if any questions.
 

mcs-51 serial sbuf

Hi
;THIS WILL SEND 'OK' VIA SERIAL PORT ON 8051
SER_INIT:NOP ;9600 Q = 11.0592
MOV PCON,#10000000B ;80H
MOV TMOD,#00100010B ;22H
MOV TH1,#0FAH
MOV TL1,#0FAH
MOV SCON,#52H
SETB TR1
RET
------------------------------------
MOV A,#'O'
MOV R6,A
LCALL SEND
MOV A,#'K'
MOV R6,A
LCALL SEND
SJMP $ ; LOOP FOREVER
SEND:JNB SCON.1,SEND
CLR SCON.1
MOV SBUF,R6
RET
 

8051 & serial mode

bill_test36 said:
:( I USER 8051 SERIAL MODE transmission DATA but no success in mode 2 and mode 3 .
how to 8051 SERIAL MODE control??? :cry:
:oops:
#include "reg51.h"

char table[10]={0x01,0x4f,0x12,0x06, /* 0,1,2,3 */
0x4c,0x24,0x60,0x0f, /* 4,5,6,7 */
0x00,0x0c}; /* 8,9 */


int KeyData=0xff;
char InputBuffer=0xff;
char OutputBuffer=0xff;

main()
{
SP=0x60;
IE=0x92;
TMOD=0x01;
TH0=(65536-2000)/256;
TL0=(65536-2000)%256;
TR0=1;
PCON&=0x7f;
SCON=0x90;
P1=table[0];
while(1)
{
KeyData=P3;
if(KeyData!=0xff)
{
if(KeyData==0x0a)
SBUF=OutputBuffer;
else if(KeyData==0x0b)
P1=table[InputBuffer];
else if(KeyData>=0 && KeyData<=9)
{
P1=table[KeyData];
OutputBuffer=KeyData;
}

}
}
}

void T0_int(void) interrupt 1 /* T0=2ms */
{
TH0=(65536-2000)/256;
TL0=(65536-2000)%256;

}

void SCON_int(void) interrupt 4
{
if(TI==1)
TI=0;
else
{
RI=0;
InputBuffer=SBUF;
}
}
 

8051 serial modes

How you check your program?
If use the terminal that remember
9 bit is no PARITY bit, is TB8
And you should SET or RESET it manually.
You use mode 2 and have BAUDrate 1/64 Fosc or 1/32 Fosc if SMOD=1.
if you use simulators, they correctly simulated not all.
Your program is not absolutely correctly written,
But to work basically can

Begin from a simplis echo
аlso do not use interruptions
I slightly modified, like should work.
But the stipulations about ninth bit and speed remain in force.

WBR, Ilya


#include "reg51.h"

char table[10]={0x01,0x4f,0x12,0x06, /* 0,1,2,3 */
0x4c,0x24,0x60,0x0f, /* 4,5,6,7 */
0x00,0x0c}; /* 8,9 */


int KeyData=0xff;
char InputBuffer=0xff;
char OutputBuffer=0xff;

main()
{
SP=0x60;
IE=0x92;
TMOD=0x01;
TH0=(65536-2000)/256;
TL0=(65536-2000)%256;
TR0=1;
PCON&=0x7f;
SCON=0x90;
P1=table[0];

// this part mods
ES=0;
RI=0;
while(1)
{

if (RI){
RI=0;
KeyData=SBUF;
SBUF=KeyData;
while(!TI){};
TI=0;
}
}
}


void T0_int(void) interrupt 1 /* T0=2ms */
{
TH0=(65536-2000)/256;
TL0=(65536-2000)%256;
}
 

mode 2 8051

Hi bill_test36

Looking at your code I saw as follows:
On P1 attached a 7 segment LED display (char table[10])
On P3 some kind of keyboard

What probably you have in mind is:
When you send 0x0b on P3 via keyboard, on P1 is displayed last byte data sent from PC to 8051 (be aware that in order to be accurately displayed you must subtract 0x30, due to the ASCII char; you can even check if the data is bounded between "0" and "9")
When you send 0x00 up to 0x09, it's displayed on P1. After you type 0x0a, the previous digit it's sent from 8051 to PC (same as above, but you have to add 0x30 in order to see on PC the number and not control chars from 0x00 to 0x09)

Thus, you must check if the baud rate on PC match the one set on 8051 in mode 2 (fOSC / 32)
You can easily calculate because you know the XTAL frequency.
Bear in mind the 0x30 mentioned above.

Regards,
Silvio
 

8051 serial transmission

hai,

use keil simulator.

u can easily find mistake.
 

serial modes of 8051

i am new on here and i totally don't understand the pcon as well as the scon register!!
someone bail me out!
 

8051 serial parity bit

I think you need to read about basics of microcontroller 8051 redisters, go here,
**broken link removed**
 

serial 8051 transmission code

i tried the link u showed me here but cannot access it!
any other links that will give me a detailed explanation
on SCON and PCON registers!
thank you!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top