Discussion in "General help Guidance and Discussion" started by    Ngel    Mar 10, 2008.
Mon Mar 10 2008, 05:59 pm
#1
i wrote this code:

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, 06:08 pm
#2
Hmm.. and crystal is 24Mhz
Mon Mar 10 2008, 07:10 pm
#3
i hope you know if you set SMOD bit, it is going to double the baud rate...
Mon Mar 10 2008, 07:16 pm
#4
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...
Mon Mar 10 2008, 07:37 pm
#5
i dont see anything on this datasheet..
http://www.keil.com/dd/docs/datashts/atmel/at89c5131_ds.pdf
Mon Mar 10 2008, 08:11 pm
#6
it's a big file try to download it
Mon Mar 10 2008, 08:40 pm
#7
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
#8
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

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Loganbag
Tue May 14 2024, 04:05 am
MichaelMog
Tue May 14 2024, 03:58 am
ThomasGaxaW
Mon May 13 2024, 05:33 pm
RobertInfup
Mon May 13 2024, 04:28 pm
Joshuatem
Mon May 13 2024, 08:30 am
RaymondPex
Mon May 13 2024, 03:24 am
Kennethbycle
Sun May 12 2024, 03:12 pm
MumerMeags
Sun May 12 2024, 01:47 pm