UART Help

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

UART Help

2,364 次查看
Rodrigo
Contributor I
Hi,

I have a M52233DEMO and I want to connect to a device at 2400 bps 8N1 and send 5 bytes via UART.
Could anyone help me configure the uart and send this string?

Thanks in advance.

Rodrigo Meireles
标签 (1)
0 项奖励
回复
2 回复数

821 次查看
PaoloRenzo
Contributor V
Inside Codewarrior sysinit.c just change the following line inside mcf52235_uart_init()

/*
* No parity, 5-bits per character
*/
MCF_UART0_UMR = (0
| MCF_UART_UMR_PM_NONE
| MCF_UART_UMR_BC_5 );


#define MY_UART_BAUD 2400

/*
* Calculate baud settings
*/
ubgs = (uint16)((SYSTEM_CLOCK*1000000)/(MY_UART_BAUD * 32));

MCF_UART0_UBG1 = (uint8)((ubgs & 0xFF00) >> 8);
MCF_UART0_UBG2 = (uint8)(ubgs & 0x00FF);

Finally don't use printf, call uart_putchar function...

Good luck
0 项奖励
回复

821 次查看
Rodrigo
Contributor I
Thanks Paolo,

I did what you said to change the uart to 2400 8N1. I tested if it worked using the windows hyper terminal but it only works using printf. The uart_putchar() function doesn't show anything in the hyper terminal.

I am modifying the "hello world" program that came with the codewarrior using the M52233DEMO UART DEBUG project.

I did like this:

int main(){

mcf52233_uart_init();
uart_putchar(0,'a');
fflush(stdout);

return 0;

}
0 项奖励
回复