sopc builder中设置波特率是9600,串口工具设置9600,发送36时,接收是FB,串口调试工具设置19200,则收到的是36,这是什么问题啊
QQ截图20120323203513.png (28.18 K)
2012-3-23 20:36:10
#include "system.h"
#include "unistd.h"
#include "altera_avalon_uart_regs.h"
#include "sys/alt_irq.h"
#include "stdio.h"
unsigned char i;
int baudrate;
void uart_irq(void *context,unsigned long id)
{
IOWR_ALTERA_AVALON_UART_STATUS(UART_232_BASE,0x0);
IOWR_ALTERA_AVALON_UART_CONTROL(UART_232_BASE,0x0);
if(IORD_ALTERA_AVALON_UART_STATUS(UART_232_BASE) & 0x80)
{
i = IORD_ALTERA_AVALON_UART_RXDATA(UART_232_BASE);
}
while(IORD_ALTERA_AVALON_UART_STATUS(UART_232_BASE) & 0x80);
IOWR_ALTERA_AVALON_UART_TXDATA(UART_232_BASE, i);
while(!IORD_ALTERA_AVALON_UART_STATUS(UART_232_BASE) & 0x40);
IOWR_ALTERA_AVALON_UART_CONTROL(UART_232_BASE,0x80);
}
int uart_init(void)
{
IOWR_ALTERA_AVALON_UART_STATUS(UART_232_BASE,0x0);
IOWR_ALTERA_AVALON_UART_CONTROL(UART_232_BASE,0x80);//开接收中断
return alt_irq_register(UART_232_IRQ, NULL, uart_irq);
}
int main(void)
{
if(!uart_init())
{
printf("successful
");
}
else
printf("unsuccessful
");
while(1)
{
IOWR_ALTERA_AVALON_UART_TXDATA(UART_232_BASE, 0x36);
usleep(1000000);
}
}
此帖出自
小平头技术问答
一周热门 更多>