Spurious NULs using uartlite

Hi there,

I have a Xilinx university program Virtex-II board and I'm trying to get my head round the serial port on it. I am using EDK and implementing a C program on a MicroBlaze, and using EDK's uartlite ip core connected to the OPB bus.

I'm using XPS 9.1.02i.

I have written a simple C program which reads one character at a time from stdin and writes its hex value to stdout. For example, if it sees an "A" character (value 0x41) it prints "" to stdout. stdin and stdout are both connected to the serial port. The program is listed here:

#include #include "xgpio.h" #include "xstatus.h" #include "xparameters.h"

int main(void) { xil_printf("\n---entering main()---\n\n"); for(;;) { unsigned char c; volatile long delay=0; while(fread(&c,1,1,stdin)) { if (c=='A') xil_printf("\r\n"); else xil_printf("",c); } xil_printf("fread returned 0\r\n"); } return 0; }

When I use a terminal program to talk to the board, the board echoes back the hex values, but after every character it also echos a zero value. For example, if I type "beef" I get the result:

This happens for all characters except for carriage return (0x0A) and line feed (0x0D), which do not get trailing NULs. All other control characters and all printable characters that I've tried have a trailing zero. (This is why I translate 'A' into a newline sequence rather than \r or \n; to make sure my program wasn't treating them any differently.)

Using Portmon I've determined that my terminal program is only sending the characters that I'd expect, it's not sending NULs that I don't want it to.

Does anyone know what the cause of these NULs is? They aren't there when they leave my computer, but they appear when they arrive at the C program on the MicroBlaze. In between is the Windows XP device driver, the link, and the opb_uartlite. I suspect the uartlite is at fault, but I'm new to EDK and I'm not sure how to go about poking at its guts.

Phil

Reply to
Philip Potter
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.