Changing UART Baud rate

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

Changing UART Baud rate

Jump to solution
4,266 Views
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 Kudos
1 Solution
785 Views
EAI
Contributor IV

You are correct.

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

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

View solution in original post

0 Kudos
8 Replies
785 Views
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 Kudos
785 Views
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 Kudos
785 Views
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 Kudos
785 Views
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 Kudos
786 Views
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 Kudos
785 Views
Jetoleg
Contributor II
Thanks a lot!
0 Kudos
785 Views
kysel
Contributor I

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

0 Kudos
785 Views
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 Kudos