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++
12606 Discussions

Weird Operation With Out PRINTF

Altera_Forum
Honored Contributor II
1,095 Views

Is anyone experiencing weird problems if you don't use any printf's in the main loop? 

 

I am having problems with using the DMA to transmit data using a UART. The UART transmits junk data (the correct number of bytes just not the correct bytes) when the printf is absent from my main loop. If I place the printf in the main loop everthing works fine. 

 

I think I also experience something similar with uClinux. From what I can remember (a month ago), my thread would not process unless I had a printf in my main loop. 

 

Has anyone else had any experiences similar to these? 

 

Thanks in advance.
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
228 Views

What are you pointing the DMA's RADDRESS (read address) towards?  

 

I don't think your issue has anything to do with whether you're using printf or not, as I've found that pointing RADDRESS at non stack-resident variables tends to work (global, statically declared variables, or malloc'ed buffers), whereas anything stack/function resident will return garbage. 

 

A simple check (to see if I'm correct) would be to add the 'static' qualifier to any of your stack-resident variables to see if that helps. 

 

Cheers, 

 

- slacker
0 Kudos
Altera_Forum
Honored Contributor II
228 Views

I point the RADDRESS at a pointer to memory that is malloced. 

 

Yeah I agree that it probably doesn't have anything to do with printf... however I cannot find any other thing to make it work right. I have a feeling that printf just does something in the system that helps the transfer along... or accesses memory in a certain way... or something... Not really sure. 

 

The funny thing is ... is that the data that is transmitted when the printf is absent is not all garbage... it is only part garbage... maybe everyother byte or so.... although I haven't looked at it in minute detail. 

 

Thansk for the reply so far... I will try making the buffer pointer static and see if that works for now.... as far as I know the data isn't on the stack... just the pointer. 

 

Any other insight into the mystery will be appreciated!
0 Kudos
Altera_Forum
Honored Contributor II
228 Views

I'm not sure what your issue could be, but perhaps the CPU's data cache could be playing a role? Have you tried the uncached malloc? 

 

Cheers, 

 

- slacker
0 Kudos
Altera_Forum
Honored Contributor II
228 Views

Ok I will try using the alt_uncached_malloc() function. I guess I also could try bypassing the cache too... by adding the 0x8x... on the front of the address. 

 

Thanks!
0 Kudos
Altera_Forum
Honored Contributor II
228 Views

Well all be darned! 

 

That worked fantastic. Using the uncached malloc worked great! The problem does not show up when using a non cached buffer. Funny thing is that the address for a non cached buffer is in the 0x8... adress range (which sets the bit to bypass the data cache). 

 

Thanks for your help! You saved me another month of agonizing does this work or does that work...
0 Kudos
Reply