Jump to content

Sending 16-bit values over RS232 - might be useful


hamster

Recommended Posts

This little module might be of use to somebody - it sends 16-bit values to an external serial device, as four ascii hexidecimal digits (eg "12AB"), with new lines and carriage returns.

http://hamsterworks.info/index.php/Hw_tx_binary_as_ascii

The sample design send the settings of the 16 slide switches every time the center button is pressed.

Link to comment
Share on other sites

@hamster,

If anyone gains some experience doing FPGA development they will find that having a few debugging tools in the toolbox is a great time saver. While simulation is a requirement and ISE and Vivado ILA tools are helpful, spitting out values to a USB serial port, when what you want to observe is intermittent or at a low data rate, or you need to capture data involving multiple clocks that are orders of magnitude apart in frequency, is a really nice thing to have. An extra bonus is that you can have most serial terminal programs log the out put to a text file or better yet use Python to capture data and write it to a text file. If you have a high data rate to capture a USB parallel data port is better though requiring a bit more work on the software side.

I've been working on a project using the old Genesys and Atlys boards to demonstrate a fast inter-board communication path and wanted to debug the incoming scan codes from the Genesys PS2 keyboard inputs. I wrote a similar debug tool. Since I don't like to reinvent the wheel my code has parametrized data length in 4-bit characters and UART baud rate. Also it has a write enable included on the input port to simplify writing n-bit words to log. Sometime you want to leave design choices to a higher level but with debugging tools I've found that making them self-sufficient is better... you'll want to instantiate them quickly with as little fuss as possible. Lastly, documenting how to use them in your code is essential.

Such tools are gifts ( whether or not you write it yourself or get it from someone else ) that keep on giving if done correctly.

PS, I was going to post a short tutorial about my keyboard/LCD debugging adventure and post my UART ASCII writer but you got the drop on me as far as the debug code goes. Kudos. Also, I like to see that you are warming up to the idea of including a wee bit more documentation in your code.... this is helpful to anyone using it... including yourself when using code written a few years back and you don't remember exactly what it is that you did.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...