Hi,
I'm coding with the serial port output and input of DEMO9S08DZ60. There is such problem: the output and input is messy code. For example, when in code I want to print a char of 'a', the output of serial port is 0xf8 with ASCII. And the input is with same problem.
Does anybody can tell me what's wrong it is? Is there any problem with configuration or others?
Thanks in advance!
Hello, and welcome to the forum.
It would seem that you may not have a sufficiently accurate baud rate. If you are using the internal reference, i.e. FEI mode, to generate the bus frequency, this will need to be trimmed to a specific frequency.
The required baud rate divisor setting is given by -
BR_divisor = fbus / 16 / baud_rate
Some bus frequencies will give more accuracy than others, especially for a high baud rate in conjunction with a low bus frequency.
Regards,
Mac
Hi, Mac,
Thank you for your reply!
Here is my configuration of baud rate: fbus is 8MHz, and BR_divisor is 10. Then the baud rate should be 50000. Isn't it?
So I think it is OK.
Do you know other possible root cause?
BR.
Leo
Hello Leo,
Assuming that you are using FEI mode to generate the bus frequency, a frequency of 8.000 MHz will require that the internal reference be accurately trimmed for a frequency of 31.25 kHz. This is achieved by a calibration process, during programming of the device, to store the appropriate trim value at a specific flash memory location. Your initialisation code then needs to transfer this value to the trim register.
If you do not trim the internal reference, the bus frequency will be subject to substantial unit-to-unit variation, much too wide for SCI operation.
Regards,
Mac