Forum Discussion
Altera_Forum
Honored Contributor
12 years agoUART and XBee and NIOS II
Hello, I need help. Based on my intensive internet search, all I need to connect to an Zigbee network using the FPGA (NIOS II) is a UART. Here are my queries: (1) Can I use IORD_AL...
Altera_Forum
Honored Contributor
12 years agoYou're nearly there...
Assuming you're right regarding the requirements of your Zigbee interface (I don't KNOW that is what it requires, but believe it is) then 'Yes' to (1) - you can use the commands you've identified to communicate with a UART peripheral connected to a Nios processor. However, I think you're code isn't quite what you want. You've correctly identified that you need to test the UART's 'STATUS' register. I assume you're intending to test whether there is a new receive character in the receive buffer. However, for that your bit mask and AND operator are incorrect. When a new character is available in the 'RXDATA' register, the 'rrdy' bit is set in the 'STATUS' register. That is bit 7 of the 'STATUS'. So you need to test if(IORD_ALTERA_AVALON_UART_STATUS(UART1_BASE) & 0X80) to establish whether there is a valid character in the receive buffer. Your current test is testing the status of 3 bits of the 'STATUS' register - transmit empty, transmit ready & receive char ready. I'm not sure why you would want to test those three bits at the same time.