Hello,I have a counter which updates at clock edge of 50Mhz frequency, which I send to Nios via PIO and print the value. But the print output is not expected, it is random, where as it suppose to be 1,2,3,....256 but it appears to be any number between 1 to 256 i.e. not in sequence. Is there a problem in sync? Secondly, I want to send this counter value on RS232, but it can be sent bit wise bit, does that implies I need to stop transmitting when RS232 is busy? But the counter is incrementing in every 50 Mhz so how to handle it? Please let me know how to proceed? Thank you
Think how fast your counter is counting. Compare that to how fast the Nios processor can print the value. If the counter is free-running at 50MHz but the processor can say only print 5 to 10 numbers per second, then you will only see every millionth or so number which will effectively appear to be random.If you want to process each number one by one, you would need some form of flow control - e.g. a flag that tells the FPGA to increment the counter which Nios can use to slow the count rate down. However if you are doing that they why bother using the FPGA to do the counting at all when you can far more simply and efficiently do the same thing in C code running on the Nios processor.
Thank you for your reply.My objective is not to implement a counter. I am using Altera project to acquire video stream from the camera. I want to send this video stream to Matlab. So I thought to use Rs232 UART, so that I can see that pixel values on the Matlab. May I have some suggestion for the same. Thank you Best regards
Hi,Additional information, the fpga works at 50 Mhz and Nios also work at 50 Mhz, that implies both should be in sync. So why there is random data, but not in sequence.
Yes both are running at 50MHz, but it takes more than a single clock cycle for the Nios processor to read the value from the counter, and then print it to wherever you are printing it to. That means the effective speed of the Nios processor is (much) lower. "Inserting a FIFO" wouldn't help with that - adding one would only slightly delay the inevitable data loss as it will rapidly fill up and overflow.It doesn't matter whether it is a counter or a video source, you need some form of flow control to ensure that the Nios can read all samples. Alternatively do away with the processor completely and simply write an HDL block which takes a value and sends it over RS232. However RS232 will probably not be fast enough for what you want to do. Even if you ran at 2MBaud which is probably on the highest end of what an RS232 transceiver could handle - i.e. 2MB of data per second - you could barely get 30FPS of 240x160 8-bit video through it. In practice you probably wont get anywhere near that either due to speed limitations of the RS232 or the fact that the software at the other end probably couldn't handle that amount of data continuously through its UART software.