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++
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.
12748 Discussions

Strange effects of UART at reset

Altera_Forum
Honored Contributor II
1,131 Views

Hello, 

 

I use an UART peripheral to communicate with a computer. If I launch the program, it works correctly, but if I reset the Nios II processor I have some problems. Here I post an simpler example where I have also the problem. The first code works correctly all the time, I receive well 1234 each time I reset the cpu. 

 

int main (void) {     printf("1234 ");     while(1); } 

 

But if i had the usleep function, that works when I launch the program, but if I reset the cpu, it the programs sends more characters than wanted. 

int main (void) {     usleep(500000);     printf("1234 ");     while(1); } 

 

I received the following (one line by reset of cpu) : 

1234  

34 1234  

1234 1234  

234 1234 1234  

4 1234 1234 1234  

1234 1234 1234 1234  

34 1234 1234 1234 1234  

 

But if I have the usleep function and I remove the while(1), I receive well 1234. Anybody have an idea why I have these effects ? 

 

Thanks in advance. 

 

Jérôme
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
370 Views

Do you still have the problem? 

If so, could you please confirm that you get longer output string ( by 3 characters or so ) string _each_ time you reset the CPU? 

At first, I thought that maybe the reset circuit had glitches and was causing the issue, but I think that would cause more random lengths, not consistently longer outputs... 

Also, you could look at the assembler output, it should be quite short ( at least for the main loop ). 

Also, you could try to change the compiler optimizer to a less optimized level. 

0 Kudos
Altera_Forum
Honored Contributor II
370 Views

Hi, 

Sorry for the late answer, I was not notifed. Yes the output strings was always longer by 3 characters after each reset. 

I noticed similar effect on others project I made. For example, I had a project where some global variables were initialized. And sometimes, after a reset, the variables were not initialized (keeping value before the reset).
0 Kudos
Reply