Forum Discussion
Altera_Forum
Honored Contributor
19 years agoNios behaving erratically?
I was wondering if anyone has encountered this strange problem... I have a scenario where I have a working code build for my particular product. however, when I add some simple code, it breaks other ...
Altera_Forum
Honored Contributor
19 years agoThanks BadOmen.
You are correct about the volatile functionality. My recollection was wrong as I hadn't looked at that topic in over a year. I guess my memory is going http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/laugh.gif As I said, the closest I've gotten to "working" software has been with the non-cached processor. I'm presently trying to cut out code to test a non-optimized version of code. Your loop looks very similar to what I'm doing. My proof of concept involved a Cypress-based USB interface for our product. I got as far as doing a simple loopback test and stalled out there due to my mysterious printf/variable problem. Below is the simple section of code. It reads until the USB chip's status shows empty. IIRC (long time since working on this problem), removing the no_activity assignment or incrementing through the data array rather than using only data[0] would break the loopback. Furthermore, I believe that if I separated the loop into two loops (read and write) using the variable j to keep track of the number points read and making that the terminal count for the writeback, the code would no longer work unless I put a printf statement in there somewhere. I could never get the two loops running. My hope was to eventually get a DMA transfer running so I could test throughput. Sorry for my vague recollections. Like I said, I abandoned the USB interface feature to finish other system features upon which I encountered the FIFO/state machine problem. Here's my loop: void USB_data_loopback(void) { volatile alt_u8 i,j; alt_u16 data[128]; alt_u16 len; no_activity = 1;// clear flag if (got_out_data) //The FLAGS int tells us we have out data { got_out_data = 0; if (IORD_ALTERA_AVALON_PIO_DATA(USB_STATUS_PIO_BASE)&0x02) { j = 0; while(IORD_ALTERA_AVALON_PIO_DATA(USB_STATUS_PIO_BASE)&0x02) { data[0] = IORD(USB_SX2_BASE, 0x00); // j++; IOWR(USB_SX2_BASE, 0x02,(alt_u16)data[0]); } . . . I am resuming my quest for a functional USB interface today. While it is not essential for our product, I need to understand this behavior as it may reappear in the essential code. I have learned a lot about the Nios tools over the past year and plan to use them, including the debugger and breakpoints. Hopefully i will find more clues. thanks. steve