Forum Discussion
Altera_Forum
Honored Contributor
15 years agoUart data ready
Hi all, I am periodically sending data from LabView to my cycloneIII development kit (bemicro) and I want to check if there is data available to be read in NIOS II. Unfortunately, I have not be...
Altera_Forum
Honored Contributor
15 years agoBy the way, here's the code I currently use for debugging. Id basically reads the STATUS bits and sends them to labview. It reads 64 continuosly, even if labview is writing onto rx...
# include <stdio.h># include <string.h># include "alt_types.h"# include "altera_avalon_spi.h"# include <altera_avalon_spi_regs.h># include "altera_avalon_uart.h"# include "altera_avalon_uart_regs.h" // these includes allow us to perform a quick sanity check that the system was properly assembled in SOPC Builder# include "system.h"# include "inc/system_validation.h"# include <stddef.h> // all helper routine includes are condensed into this one file for neatness# include "inc/main_includes.h"# include "sys/alt_irq.h" alt_u16 status = 0; int main(void) { alt_u16 new_divisor; //clk speed divisor to uart speed alt_u32 serial_speed = 1000000; //uart speed, as to be match with labview VI. max 1250000 alt_u32 FPGA_CLK = 50000000; //set at 50Mhz in Quartus uart_init(); // see src/uart_util.c new_divisor = (alt_u16)(FPGA_CLK/serial_speed+0.5); //set the divisor for the uart speed wanted IOWR_ALTERA_AVALON_UART_DIVISOR(UART_BASE, new_divisor); validate_me(); while(1) //loop for the run|| { if (IORD_ALTERA_AVALON_UART_STATUS(UART_BASE) & ALTERA_AVALON_UART_STATUS_TRDY_MSK) { status = IORD_ALTERA_AVALON_UART_STATUS(UART_BASE); IOWR(UART_BASE,0x01, status); } }