Changing UART Baud rate

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Changing UART Baud rate

ソリューションへジャンプ
4,842件の閲覧回数
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 解決策
1,361件の閲覧回数
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 返答(返信)
1,361件の閲覧回数
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 件の賞賛
返信
1,361件の閲覧回数
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 件の賞賛
返信
1,361件の閲覧回数
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 件の賞賛
返信
1,361件の閲覧回数
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 件の賞賛
返信
1,362件の閲覧回数
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 件の賞賛
返信
1,361件の閲覧回数
Jetoleg
Contributor II
Thanks a lot!
0 件の賞賛
返信
1,361件の閲覧回数
kysel
Contributor I

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

0 件の賞賛
返信
1,361件の閲覧回数
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 件の賞賛
返信