MCU User Forum
  Tx using the C8051F30x

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   Tx using the C8051F30x
DavidGMarcus
New Member
posted July 28, 2010 10:27 AM     Click Here to See the Profile for DavidGMarcus   Click Here to Email DavidGMarcus     Edit/Delete Message
I am using the C8051F30x and I am trying to Transmit for right now a character "A" to the computer.(Basic I know) When using the SI labs dev board for the C8051F30x I set my baud rate to 9600 and the Character that I write out is the character I receive. However when I change the baud rate to 4800 the character that I write out is not what i receive. I receiver a U with 2 dots above it. I then compared the signals of the Character A from the computer a 4800 Baud to that of a character A coming out of the C8051F30x. They are the same signal except the one coming from the computer is much more compact.(Computer's A=4ms C8051F30x's A= 11ms) Why is my signal almost 3 times longer than the computers?

Below is my intialiation for the UART after i define the Baud to be 4800:

void UART0_Init (void)
{
SCON0 = 0x10; // SCON0: 8-bit variable bit rate
// level of STOP bit is ignored
// RX enabled
// ninth bits are zeros
// clear RI0 and TI0 bits


if (SYSCLK/BAUDRATE/2/256 < 1) {
TH1 = -(SYSCLK/BAUDRATE/2);
CKCON |= 0x10; // T1M = 1; SCA1:0 = xx
} else if (SYSCLK/BAUDRATE/2/256 < 4) {
TH1 = -(SYSCLK/BAUDRATE/2/4);
CKCON |= 0x01; // T1M = 0; SCA1:0 = 01
CKCON &= ~0x12;
} else if (SYSCLK/BAUDRATE/2/256 < 12) {
TH1 = -(SYSCLK/BAUDRATE/2/12);
CKCON &= ~0x13; // T1M = 0; SCA1:0 = 00
} else {
TH1 = -(SYSCLK/BAUDRATE/2/48);
CKCON |= 0x02; // T1M = 0; SCA1:0 = 10
CKCON &= ~0x11;
}

TL1 = 0xFF; // Set Timer1 to overflow immediately
TMOD |= 0x20; // TMOD: timer 1 in 8-bit autoreload
TMOD &= ~0xD0; // mode
TR1 = 1; // START Timer1
TI0 = 1; // Indicate TX0 ready

IP: Logged

erikm
Member
posted July 28, 2010 11:07 AM     Click Here to See the Profile for erikm   Click Here to Email erikm     Edit/Delete Message
I then compared the signals of the Character A from the computer a 4800 Baud to that of a character A coming out of the C8051F30x. They are the same signal except the one coming from the computer is much more compact.
the baudrate setting is wrong.
4800 baud ~ 480 chars ~ 20ms/char.

Note that config, while excellent, is not error free, use the formula in the datasheet

A better way is to constantly transmit uppercase U and measure the bit time.

Erik

[This message has been edited by erikm (edited July 28, 2010).]

IP: Logged

worknhard9062
Member
posted July 28, 2010 12:30 PM     Click Here to See the Profile for worknhard9062   Click Here to Email worknhard9062     Edit/Delete Message
4800 baud ~ 480 chars ~ 20ms/char.

Of course you meant 2ms/char.

------------------
Regards,
Steve C.

IP: Logged

erikm
Member
posted July 28, 2010 01:27 PM     Click Here to See the Profile for erikm   Click Here to Email erikm     Edit/Delete Message
ah, that basted decimal point, it often get me in trouble

Erik

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | MCU User Forum

Have you seen our MCU Knowledge Base?


Ultimate Bulletin Board 5.47b