AT89C5131 set as 9600baud?
Discussion in "General help Guidance and Discussion" started by Ngel Mar 10, 2008.
Mon Mar 10 2008, 05:59 pm
i wrote this code:
and run it on my mcu to start communicate with my new xbee.
but after sending an "X" (just for check) and after sending "+++" i'm still aint getting "OK".
so i think it's becuse that it's not an 9600baud rate...
my question:
is this function se the mcu to 9600baud, no parity and 1 stop and 1 start?
(by the datasheet it shoud )
void init_serial(void) { SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */ BDRCON &=0xEC; /* BRR=0; SRC=0; */ BDRCON |=0x0C; /* TBCK=1;RBCK=1; SPD=0 */ BRL=100; /* 9600 Bds at 24MHz (page 72)*/ //X2=1 (page 22) CKCON0|=0x01; //SMOD1=1 (page 74) PCON|=0x80; //SPD=1 BDRCON|=0x02; ES = 1; /* Enable serial interrupt */ EA = 1; /* Enable global interrupt */ BDRCON |=0x10; /* Baud rate generator run*/ return; }
and run it on my mcu to start communicate with my new xbee.
but after sending an "X" (just for check) and after sending "+++" i'm still aint getting "OK".
so i think it's becuse that it's not an 9600baud rate...
my question:
is this function se the mcu to 9600baud, no parity and 1 stop and 1 start?
(by the datasheet it shoud )
[ Edited Mon Mar 10 2008, 07:01 pm ]
Mon Mar 10 2008, 07:10 pm
i hope you know if you set SMOD bit, it is going to double the baud rate...
Mon Mar 10 2008, 07:16 pm
i know :O
http://www.ortodoxism.ro/datasheets/atmel/doc4136.pdf
page 72, to have 9600baud brl=100 and x2=1, smod1=1 spd=1...
http://www.ortodoxism.ro/datasheets/atmel/doc4136.pdf
page 72, to have 9600baud brl=100 and x2=1, smod1=1 spd=1...
Mon Mar 10 2008, 07:37 pm
i dont see anything on this datasheet..
http://www.keil.com/dd/docs/datashts/atmel/at89c5131_ds.pdf
http://www.keil.com/dd/docs/datashts/atmel/at89c5131_ds.pdf
Mon Mar 10 2008, 08:40 pm
oh, there is BRL, it's the baud rate generator, you put in the BRL a value by the table to get an baud rate as you wish, and on top of the table there is the other registers to be configured.
Mon Mar 10 2008, 11:19 pm
read description about SMOD1 twice... from both the PDF. I did not find place where anything like that is mentioned.
Please do read about PCON in table 59 on page 73
Please do read about PCON in table 59 on page 73
Powered by e107 Forum System