谁帮我看下这NIOS串口程序问题在哪?
能收到 不能发送#include "system.h"
#include "altera_avalon_uart_regs.h"
#include "altera_avalon_pio_regs.h"
#include "sys/alt_irq.h"
#include "alt_types.h"
//UART发送一个字节子程序
void Uart_send(unsigned char data)
{
alt_u16 status;
IOWR_ALTERA_AVALON_UART_TXDATA(RS232_BASE,data);
status=IORD_ALTERA_AVALON_UART_STATUS(RS232_BASE);
while(!(status&0x0040))//等待发送完成
}
//UART发送多个字节子程序
void Uart_send_n(unsigned char *ptr,unsigned char n)
{
for(;n>0;n--)
{
Uart_send(*ptr);
ptr++;
}
}
//串口接收中断服务程序
void Uart_ISR(void * context,alt_u32 id)
{
unsigned char temp;
temp=IORD_ALTERA_AVALON_UART_RXDATA(RS232_BASE);
led=temp;
}
//串口中断初始化
void Uart_init(void)
{
IOWR_ALTERA_AVALON_UART_CONTROL(RS232_BASE, 0x80);//接收中断使能
IOWR_ALTERA_AVALON_UART_STATUS(RS232_BASE, 0x00);//清状态标志
IOWR_ALTERA_AVALON_UART_RXDATA(RS232_BASE, 0x00);//清接收寄存器
alt_irq_register(RS232_IRQ, 0, Uart_ISR);
}
int main (void)
{
volatile int i;
Uart_init();
while (1)
{
Uart_send(0xff);
IOWR_ALTERA_AVALON_PIO_DATA(PIO_LED_BASE, led);
i = 0;
while (i<90000)
i++;
}
return 0;
} 没问题 脚错了
页:
[1]