Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

[URGENT] How to receive a string from UART ?

Altera_Forum
Honored Contributor II
2,328 Views

Hi! I am only able to receive the last char from the UART and was wondering how can I receive a string from UART 

 

HyperTerminal -> UART -> Terminal 0 (Nios II Console) 

 

I am using Nios II C Programming I guess... Please Help Me! Thank You!
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
1,043 Views

Hi, which board, which NIOS II program, which UART driver ? 

 

In almost programs for beginner ("getting started", tutorials), every time you send a character to UART, it triggers an interruption and copy it to the Nios II Terminal. 

 

A string is a suite of characters.  

So what is the problem ? You want Terminal to print the entire string ? You have to memorize the characters until a Carrier Return is received and after print it to terminal... 

 

Regards.
0 Kudos
Altera_Forum
Honored Contributor II
1,043 Views

 

--- Quote Start ---  

Hi, which board, which NIOS II program, which UART driver ? 

 

In almost programs for beginner ("getting started", tutorials), every time you send a character to UART, it triggers an interruption and copy it to the Nios II Terminal. 

 

A string is a suite of characters.  

So what is the problem ? You want Terminal to print the entire string ? You have to memorize the characters until a Carrier Return is received and after print it to terminal... 

 

Regards. 

--- Quote End ---  

 

 

 

Hi! I am able to receive a string from the HyperTerminal and send it toDE2_115 Altera Board using C Programming but I am unable to detect the carriage return ? i compare it with \r but it didn't get into the loop.
0 Kudos
Altera_Forum
Honored Contributor II
1,043 Views

try with '\n'

0 Kudos
Altera_Forum
Honored Contributor II
1,043 Views

I tried to compare with the message I get but it still doesn't works... 

is there any other way?
0 Kudos
Altera_Forum
Honored Contributor II
1,043 Views

Are you beginner in C program ? 

Comparing strings in C is not so easy as comparing integers. Keep in mind that a string in C is terminated by a NULL character '\0' 

You can compare a suite of characters. 

 

Before comparing, just try to simply print the received strings. 

 

The output may be buffered. So "printf" seems to not work. You can "force" the print by adding a function that looks like "flush()". 

 

 

could you please tell us what you exactly want to do ?
0 Kudos
Reply