[求助]大家帮我看看这段uart程序为什么不能进中断
- UID
- 99281
- 性别
- 男
|
[求助]大家帮我看看这段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); }
|
|
|
|
|
|
- UID
- 123791
- 性别
- 男
|
|
|
|
|
|
- UID
- 123791
- 性别
- 男
|
while(!((IORD_ALTERA_AVALON_UART_STATUS(UART0_BASE)) &ALTERA_AVALON_UART_STATUS_TRDY_MSK));
是查询方式啊 |
|
|
|
|
|