Changing UART Baud rate

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Changing UART Baud rate

跳至解决方案
4,380 次查看
Jetoleg
Contributor II

Hi,

I am using eval version of CodeWarrior IDE 7.1.1 with M52259DEMO board. MQX build 3.1

Could anyone tell me how to change baud rate and other UART parameters under MQX? Documentation is kind off vague on details.

For the starter, could you show me how to change baud rate for ttya UART for printf output in MQX "hello world" example? Default speed in example is 115200.

0 项奖励
回复
1 解答
899 次查看
EAI
Contributor IV

You are correct.

printf uses stdout, so use ioctl(stdout,...

Message Edited by EAI on 2009-05-27 10:37 PM

在原帖中查看解决方案

0 项奖励
回复
8 回复数
899 次查看
JaimeR
Contributor III

You will need to open the BSP library.

Then search in all files (ctrl + shift +m) ttya (which is the name for the uart).

Then you will see the parameters you need to change. 

After you change them, dont forget to rebuild the library.

 

 

 

0 项奖励
回复
899 次查看
EAI
Contributor IV
No need to rebuild the BSP - just use ioctl to set the baud. See section 5.7 of I/O manual.
0 项奖励
回复
899 次查看
Jetoleg
Contributor II

Thanks for suggestion. So I assume something like following will set baud rate to 9600?

 

uint_32 baud=9600;

FILE_PTR serial_fd =  fopen("ttya:",0);
ioctl(serial_fd,IO_IOCTL_SERIAL_GET_BAUD, &baud);

 

Fine with me.

One more quetion "Hello World" example using prinf for output. I assume above example must use fprintf instead. Is any way to change baud rate for printf?

0 项奖励
回复
899 次查看
Jetoleg
Contributor II

I correct one before, IMHO right way would be a


ioctl(serial_fd,IO_IOCTL_SERIAL_SET_BAUD, &baud);

 

Correct me if wrong.

 

0 项奖励
回复
900 次查看
EAI
Contributor IV

You are correct.

printf uses stdout, so use ioctl(stdout,...

Message Edited by EAI on 2009-05-27 10:37 PM
0 项奖励
回复
899 次查看
Jetoleg
Contributor II
Thanks a lot!
0 项奖励
回复
899 次查看
kysel
Contributor I

and how to send byte not a character ?? eg. 0xfffe12

0 项奖励
回复
899 次查看
Jetoleg
Contributor II

So all the changes for UART must be hardcoded on BSP level!? It's very inconvenient.

I need to change UART parameters on the fly during MCU runtime.

I can't find any complete UART application example in my MQX distribution. I am new to this OS platform, so good set of examples would be really nice to have.

 

0 项奖励
回复