Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Writing to UART

Altera_Forum
Honored Contributor II
864 Views

Simple code, trying to write to UART from terminal and light an LED if character "A" is detected. What am i doing wrong? here is the code. The manual of UART is here under \devices: http://www-ug.eecg.toronto.edu/msl/nios.html 

# include <stdio.h># define RS232_UART_DATA ((volatile int*) 0x10001010)# define RS232_UART_CONTROL ((volatile int*) (0x10001010+4)) 

volatile int*LED =(int*)0x10000010; 

 

 

int main() 

 

 

unsigned char *pinput; 

 

while(*pinput){ 

//strings in C are zero terminated 

 

//if room in output buffer 

if((*RS232_UART_DATA)&0xffff0000 )  

//then read the next character 

*(pinput)= *RS232_UART_DATA;  

if (pinput =='A'){ 

*(LED)=1; } 

 

 

 

 

}
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
108 Views

Check your compiler warnings. 'pinput' is an uninitialized pointer variable and it's entirely possible it is pointing at garbage memory containing a zero when your program starts.

Altera_Forum
Honored Contributor II
108 Views

do confirm if the value that pinput is holding when any car detected.

Reply