MCF52255 Baud rate

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCF52255 Baud rate

Jump to solution
873 Views
blakehodder
Contributor III

I am using the MCF52255 with a 48MHz crystal and set at a system bus of 80MHZ. I am attemting to set up my uart at 9600 as follows:

 

MCF_UART0_UCR = 0x00 | MCF_UART_UCR_RESET_RX;
MCF_UART0_UCR = 0x00 | MCF_UART_UCR_RESET_TX;
MCF_UART0_UCR = 0x00 | MCF_UART_UCR_RESET_MR;
MCF_UART0_UMR1 = 0b00010011;
MCF_UART0_UMR2 = 0b00000111;
MCF_UART0_UIMR = 0x00;
MCF_UART0_UACR = 0x00;
MCF_UART0_UCSR = 0xDD;
MCF_UART0_UBG1 = 0x01;
MCF_UART0_UBG2 = 0x04;
MCF_UART0_UCR = 0x00 | MCF_UART_UCR_TX_ENABLED;

 

However the baud rate ends up starting at 1612 and then seems to keep changing. Any help?

 

Thanks,

 

Blake

Labels (1)
0 Kudos
1 Solution
640 Views
blakehodder
Contributor III

Hi Tom,

It Turned out I was pushing the uart to hard. Once I put in a delay loop it worked fine.

View solution in original post

0 Kudos
5 Replies
640 Views
TomE
Specialist II

I'd suggest following "28.5.2 UART Module Initialization Sequence" exactly, and setting up UCSR and the baud rate before writing to UMR.

Then I'd suggest googling for a keyword like "MCF_UART0_UBG1" and looking for someone else's working code to copy. You'll find 5 matches in these forums, I'd read them first in case this is a common problem.


What do you mean "ends up starting at 1612"? How are you measuring this? If you're measuring the serial line with a CRO then six one or zero bits in a row will have an apparent baud rate of 1600.

Tom

0 Kudos
640 Views
blakehodder
Contributor III

Hi Tom,

Thanks, I tried setting the baud rate before writing to UMR but no change. I am googling it now.

Whats happening is I am using a logic analyzer to watch the output and if I use auto baud it detects the right value for a bit at 1612 and then I set the baud rate detection on the logic analyzer statically to 1610 and it will receive a clear character which still continues to change even though all I am sending is 0x4A. I am setting the baud rate in my code to 9600.

0 Kudos
640 Views
TomE
Specialist II

Autobaud is lying to you. You're misleading it by sending it the wrong characters, so it is misleading you in return.

Autobaud works by measuring the width of the Start Bit. Which is followed by data bits 1 to 8 (or 7 or whatever).

Autobaud was first widely implemented on Modems, and for it to work, the modem commands always start with the characters "AT". There's a reason for that. "A" is 0x41 or 0b01000001, or as a string of bits on the serial port, "S10000010s" where the first "S" is the Start bit with the value of "0" and the "s" is the Stop bit. So the serial port has the bit stream "....1111111010000010111111..." That first zero is the start bit and the width of that is what the Autobaud measures. The "T" is 0x54 or 0b01010100, and in combination with the "A" the modem can work out the number of bits and the parity as well. It also works with "at".

Autobaud also works on Carriage Return as that's 0x0D or 0b00001010, but it can only tell the baud rate.

If you're sending 0x4A (a "J"???), then that's 0b01001010 which will be "...1111110010100101111..." and I'd expect "Autobaud" to measure that as 4800 baud as it would see the first two zeros as a single bit.

So forget Autobaud. Look at the actual waveform and decode it yourself.

Are you sure your system clock is 80MHz? Have you measured that separately? Can you enable CLKOUT and measure its frequency?

Tom

641 Views
blakehodder
Contributor III

Hi Tom,

It Turned out I was pushing the uart to hard. Once I put in a delay loop it worked fine.

0 Kudos
640 Views
JimDon
Senior Contributor III

You can accept that as the correct answer, but I wouldn't. Often, delay loops just mask a problem until later, in this case until you need to send characters and the maximum rate.

You should not need a delay loop your code should test register status until it is ready for the next character, then send it.

0 Kudos