That is not an AVR, but an 8051 device. Maybe someone can help here, but you could perhaps have more success at one of the 8051 lists or forums.
Jim Wagner
Oregon Research Electronics
----- Original Message -----
From: "alex_p_silva" <alex_p_silva@yahoo.com.br>
To: AVR-Chat@yahoogroups.com
Sent: Thursday, July 5, 2012 1:30:25 PM
Subject: [AVR-Chat] help with AT89S52
Could someone help me I'm trying to make a serial with AT89S52 but they are funny characters and not real (test simulator proteus)
My code is as follows if anyone can tell what I'm doing wrong, I'm with 12MHz oscillator, I want a baud rate of 9600 even 1
include <at89x52.h>
volatile char acceptext;
volatile __bit status=0;
void IntSerial()__interrupt 4 __using 1
{
ES=0;
RI=0;
status = 1;
acceptext = SBUF;
ES=1;
}
void inituart(void) // serial port initialization
{
SCON = 0x50; // uart in mode 3
//PCON = 0x00;
TMOD = 0X20; // timer 1 in mode2
TH1 = 0xfd ;// setting baudrate 9600 bps
//TL1 = 0xfd;
ES=1 ; // enable serial interrupt
EA = 1 ; // enable global interrupt
TR1 = 1 ; // start timer 1 running
}
void sendchar(char datasent) // for sending one charater
{
SBUF = datasent;
while (!TI)
{;}
TI = 0;
}
void sendtext(char *text) //for sending text
{
char i=0;
while (text[i]!=0)
{
sendchar(text[i]);
i++;
}
sendchar(13);
sendchar(10);
}
void delay100ms()
{
__asm
push ACC
mov a,#149
L0:
push ACC
mov a,#170
L1:
nop
nop
djnz acc,L1
nop
nop
pop ACC
djnz acc,L0
nop
pop ACC
__endasm;
}
void main(void)
{
inituart();
while (1){
sendtext("TRIAL 1");
P1=0X50;
P2=0X50;
delay100ms();
P1=0X00;
P2=0X00;
delay100ms();}
}
[Non-text portions of this message have been removed]Message
Re: [AVR-Chat] help with AT89S52
2012-07-05 by Jim Wagner
Attachments
- No local attachments were found for this message.