adisas91
Newbie level 3
Guys,
Am new to this forum, Please help me with this bit of code I have written for syncmos sm59r16a3,
I am actually writing this code to receive a byte of data from pc, if the data's MSB is set to one it is written to port 1 or if it is 0 it is written to port 0.
The max 232 circuit has been purchased from a store, so there's no problem with it.
Now when I turn on my MC, it automatically turns port 0 and port 1 high, irrespective of whether or not its receiving any data from the pc.
Also am thinking of using 19200 baud rate, is it safe?
Also **broken link removed** is the link to syncmos datasheet for reference
Am new to this forum, Please help me with this bit of code I have written for syncmos sm59r16a3,
I am actually writing this code to receive a byte of data from pc, if the data's MSB is set to one it is written to port 1 or if it is 0 it is written to port 0.
The max 232 circuit has been purchased from a store, so there's no problem with it.
Now when I turn on my MC, it automatically turns port 0 and port 1 high, irrespective of whether or not its receiving any data from the pc.
Code:
#include<reg52.h>
unsigned char AA,BB,x;
void intiserial(void)
{
TCON=0X00;
TMOD=0X21;
SCON=0x50;
TL1=0XFD;
TH1=0XFD;
TR1=1;
ES=1;
}
void delay(unsigned int x)
{
unsigned int i;
for(i=0;i<=x;i++)
{
TH0=0XFC;
TL0=0X17;
TR0=1;
while(!(TF0==1));
TR0=0;
TF0=0;
}
}
void MOTOR(void) interrupt 4
{
EA=0;
RI=0;
x=SBUF;
if(x&0x80)
BB=x;
else
AA=x;
delay(250);
EA=1;// Enables interrupts
}
void main()
{
intiserial();
AA=0x00;
BB=0x00;
EA=1;
while(1)
{
P0=AA;
P1=BB;
}
}
Also am thinking of using 19200 baud rate, is it safe?
Also **broken link removed** is the link to syncmos datasheet for reference