- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to send char bytes from my fpga to a python program, the data bytes are hexadecimal data, and those values will be plotted in a GUI table. The nios code is
unsigned char temp =0xa; unsigned char temp1 =0xb; unsigned char temp2 =0xc; while(1) { sendFloat(temp); sendFloat(temp1); sendFloat(temp2); } return0; } void sendFloat( unsigned char n) { char number[20]; int i=0; snprintf(number, sizeof(number),"%u", n); while(i<20){ IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE,number[i]); delay(); i++; } IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE,'\n');} The Python code is import serial ser= serial.Serial('COM5',baudrate =115200, timeout=1) while 1: fpgadata=ser.readline() print(fpgadata)Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your Nios code doesn't show whether you setup your Baudrate correctly - or at all. (Depending on your FPGA design you may not need to. However, it will need setting up somewhere.)
Refer to chapter 7 - UART Core - of the "embedded peripherals ip user guide (https://www.altera.com/en_us/pdfs/literature/ug/ug_embedded_ip.pdf)". This has some code you can crib from too. Python looks adequate. Lookup the "Serial.inWaiting()". I think you'll find it helpful. Cheers, Alex- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your reply, actually i forgot to mention the problem there was also some random garbage values were printed with actual data.
But i got the solution for my problem, the char number[20] should be number[2]
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page