Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12600 Discussions

NIOS II - UART scanf limitation

ASeif
Beginner
1,781 Views

Hello everyone,

I use NIOS II to implement a program.

The program is loading 'In Place' [at EPCS16 memory].

The "scanf" function does not work properly if it wants to get more than 4-byte at once.

For example

... unsigned char RX[8]; scanf("%c%c%c%c%c%c%c%c", &RX[0], &RX[1], &RX[2], &RX[3], &RX[4], &RX[5], &RX[6], &RX[7]); ...

This code sometimes does not fill "RX" when I send 8-byte from PC terminal (yes! I trusted the terminal).

 

However if I reduce the input length to 4-byte at once the problem is vanished.

 

Do have any idea what is wrong?

Is there any suggestion?

Is that related to 'In Place' execution things?

 

0 Kudos
3 Replies
Ahmed_H_Intel1
Employee
1,457 Views

Hi,

First of all the scanf() family of routines is supported in the Normal C but NOT in the Small C library, so please make sure to use the normal C library. Using the execute in place on an EPCS16 may cause some delay, I do suspect the delay to be the cause but there is no evidence. Any way can you please re-write it as the following and see the result? getting a string should be more efficient.

 

#include <stdio.h> int main() { char RX[8]; scanf("%s", &RX); }

 

0 Kudos
ASeif
Beginner
1,457 Views

Thanks you for sharing your opinion.

Yes, normal C is used here.

scanf with string also was not working. But for sake of curiosity, would you please explain why string is more efficient than character?

 

BTW, an important note is that serial communication sends out a binary value in each bytes in packet. Therefore, working with string maybe have some problems because of unwanted termination.

0 Kudos
Ahmed_H_Intel1
Employee
1,457 Views

Hi,

I would like to see if the string will arrive missing any thing or not. The Char cannot show you what is going on, I am still suspecting the EXP delay.

Regards,

 

0 Kudos
Reply