MC9S08PA4 - Uart 115200 - SCI0_D errors

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

MC9S08PA4 - Uart 115200 - SCI0_D errors

771 Views
giacomoguarrier
Contributor II

Hello All,

 

i'm using a freescale micro, MC9S08PA4 family.

Using Uart in polling, i find a problem when setting baud rate to 115200, trasmitting ascii character, these ones will be corrupted.

I mean, sending char 'S'= 0x53, i receive 0x83 Hex value.

I tried to set all the bites of internal data register (SCI0_D) but nothing. 

I make a series of testings, and as results this corruption happended only when using this specific baudrate.

The same datas sended, once setted different baudrate, doesn't happend. Someone could help me or explain why happend this?

 

Thanks!

Labels (1)
7 Replies

493 Views
giacomoguarrier
Contributor II

Hello Tony,

nice to meet you!

The Micro was perfectly trimmed to 8601600Hz, with trim value and i tried to ha 256000 of baud rate. Every values measered with oscilloscope was in the baudrate mismatch tollerance of 4,5% for 8 bit transmission.

So i think could be the driving of PE and PT register!!!

i receive datas to the same baudrate without prolems, so.....!!!

Could be them? What do you think about?

0 Kudos

493 Views
tonyp
Senior Contributor II

Like I already said, check your bus speed, which as it turns out is not compatible with 115200 baud.  Do the math:

8601600/(115200*16) = 4.666...

So, you can either use 4 or 5 (5 being closer).

With 4 you have: 8601600/4/16 = 134400 bps, a 16.66% difference.

With 5 you have: 8601600/5/16 = 107520 bps, a 6.66% difference.

Either one of these is way off when the maximum should be around 4 to 5%.

(Doing the same for 256000 bps has a 5% mismatch.  So, that's on the border line between working and not.)

(I don't know what you measure with the oscilloscope.  The math shows something else.  Unless, of course, I completely messed it up.)

0 Kudos

493 Views
giacomoguarrier
Contributor II

Hello Tony,

i used 5 to set 115200 and 2 to set 256000 and 14 for 38400. The target it's to send startup datas to 115200bps, after switch to 38400bps for normal comunication. Now, i'll try to use different SCI module clock and set to 36 Khz clock.

Think could be a solution?

0 Kudos

493 Views
tonyp
Senior Contributor II

Yes, if you can afford to change your bus speed to something different, then 9216000Hz (512*36000/2) will allow your 115200 baud rate.

9216000/115200/16 = 5 exactly (zero deviation for 115.2Kbps)

9216000/38400/16 = 15 exactly (zero deviation for 38.4Kbps)

This should definitely work for both bps rates you need.

493 Views
giacomoguarrier
Contributor II

Hello Tony,

thanks for your help.

I used your settings and the real deviation measured with oscilloscope it's:

Displaying image.png

Anyway, it's work fine!!!

Thanks,

Regards.

0 Kudos

493 Views
tonyp
Senior Contributor II

I cannot see the image.  But, I assume there is still some deviation from the true baud rate.

Whatever deviation is there is the result of the inherent inaccuracy of the trimmed MCU.  If you read the specs, you'll see that a trimmed MCU has a small error tolerance in itself (I think it's about 2%).  It's certainly not even close to being as accurate as using a crystal, and this frequency error even varies from one MCU to the next.  But, being exactly on the baud frequency means that you're still below the 5% margin for successful SCI comms.

This should explain whatever true deviation you're still seeing.  But, at least now you're 'theoretically' correct with these numbers, and if you decide to use an actual crystal you'll be exactly on the frequency.

0 Kudos

493 Views
tonyp
Senior Contributor II

This sounds like either an untrimmed MCU, or simply that this baud rate in relation to your bus speed is not possible, i.e., it has an error (deviation from the actual baud) that is too large to work reliably.

0 Kudos