Forum Discussion
13 Replies
- Altera_Forum
Honored Contributor
I'd write any data or logging info directly to standard output. I use the logging feature of PuTTy to capture the data. fopen isn't needed.
- Altera_Forum
Honored Contributor
Dear Galfonz,
Can you clarify your idea for me ? How i should use puTTy to capture data? whether the puTTy capture data after using printf() function of stdio.h? what software do i need? can you upload it for me? Thanks - Altera_Forum
Honored Contributor
PuTTY is a serial terminal emulator. Google "PuTTY download" to find it. This one works fine for me but there are several others.
Your dev board probably has a hello, world example. Get that running. Then replace that software with your own code. Write you data to standard output using printf. Look at the PuTTY (or other terminal emulator) documentation to find out how to log console output to a file on your PC. Just be sure you don't write data faster than the serial port can handle. Slow down if you start missing characters. You can then use excel, matlab, etc to analyze your data. - Altera_Forum
Honored Contributor
ok. when I captured data using HyperTerminal, I saw some jump in my data. I think my serial port have a problem. So I want to log data using open and printf. because I think by this method that serial port do not involved. what is your opinion ? in this state puTTy is similar to HyperTerminal and it do not help me.
t - Altera_Forum
Honored Contributor
For open and write/printf to work you need a file system. The NIOS II does not have a file system unless you include some storage device and a device driver for it. You can either log the data on the serial port as suggested. Another alternative is to use the JTAG serial port if your real serial port have issues as you described (or try to lower the serial port speed to see if it helps). Another method would be to include some serial file transfer protocol which includes error check and retry, e.g. kermit or x/y/zmodem.
- Altera_Forum
Honored Contributor
When you see dropped characters, it is due to bytes being written to the serial port faster than they are output at the baud rate the port is using. At some point the FIFO will fill up and you will start losing characters. If just a few bytes are missing you could try raising the baud rate. Otherwise insert delays in your code, after every data line, or after every byte if you UART has a small FIFO. You could also see if your UART (including its driver) and USB<->serial chip implement hardware or software based flow control. See an RS232 tutorial for more info.
- Altera_Forum
Honored Contributor
Thanks all. Mr. Peter i want to log data using Jtag UART. if it is not possible (I can not open a file and write to it), i should fix my UART port.Have you an idea?
- Altera_Forum
Honored Contributor
The JTAG UART works just like a regular UART, but is using the JTAG connection, e.g. your USB Blaster. Note that the JTAG UART is quite slow. If you generate data faster than your UART is running you will experience data loss due to overrun. Check that your UART is fast enough to handle your data rate. You can enable the JTAG UART in your NIOS software.
Check by lowering the speed of your real UART if you're having signal integrity problems. If it gets worse you're problem might be related to overruns. - Altera_Forum
Honored Contributor
Thanks Peter. I want to store up to 4-byte data per 1ms (or 32000bps). I think that i will not experience data loss. now my problem is Error by opening a file by command fopen(). But we can able to use New lib C Commands (fopen()) according to Nios II Software Developer’s Handbook. what is my mistake?
- Altera_Forum
Honored Contributor
That should work if you capture binary data. But if you convert to ASCII (printf("%x")) you need 10 times the binary generation rate, which will exceed 115200 (I don't know what your actual UART rate is).
In order to use fopen and fwrite your system must have some kind of storage and a driver interface to the storage.