标题:
[求助]大家帮我看看这段uart程序为什么不能进中断
[打印本页]
作者:
jsliujin
时间:
2006-1-12 21:32
标题:
[求助]大家帮我看看这段uart程序为什么不能进中断
就是下面这段程序,为什么不能进中断服务程序呢
#include "alt_types.h"
#include "altera_avalon_pio_regs.h"
#include "system.h"
#include "sys/alt_irq.h"
#include "altera_avalon_uart_regs.h"
#include "altera_avalon_uart.h"
static alt_u8 dat[3] = {0x85,0x89,0x91};
static alt_u8 recv[3] = {0};
alt_u16 uart0control;
alt_u16 uart0state;
alt_u8 num;
void HANDLE_UART0_interrupts(void * context,alt_u32 id)
{
uart0state = IORD_ALTERA_AVALON_UART_STATUS(UART0_BASE);
IOWR_ALTERA_AVALON_UART_STATUS(UART0_BASE, 0);
if (uart0state & ALTERA_AVALON_UART_STATUS_RRDY_MSK)
{
recv[num++] = IORD_ALTERA_AVALON_UART_RXDATA(UART0_BASE);
}
if (uart0state & ALTERA_AVALON_UART_STATUS_TRDY_MSK)
{
IOWR_ALTERA_AVALON_UART_TXDATA(UART0_BASE, 0x64);
}
}
int main (void) __attribute__ ((weak, alias ("alt_main")));
int alt_main()
{
alt_u8 counter ;
num = 0;
uart0control = 0x00c0;
IOWR_ALTERA_AVALON_UART_CONTROL(UART0_BASE, uart0control);
alt_irq_register(UART0_IRQ,0,HANDLE_UART0_interrupts);
for (counter = 0; counter < 3; counter ++)
{
IOWR_ALTERA_AVALON_UART_TXDATA(UART0_BASE, dat[counter]);
while(!((IORD_ALTERA_AVALON_UART_STATUS(UART0_BASE)) &ALTERA_AVALON_UART_STATUS_TRDY_MSK));
}
IOWR_ALTERA_AVALON_UART_TXDATA(UART0_BASE, 0xa5);
while (1);
return (0);
}
作者:
meling
时间:
2006-4-9 23:46
我也有同样的问题
谁能给点指点
作者:
meling
时间:
2006-4-9 23:52
while(!((IORD_ALTERA_AVALON_UART_STATUS(UART0_BASE)) &ALTERA_AVALON_UART_STATUS_TRDY_MSK));
是查询方式啊
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/)
Powered by Discuz! 7.0.0