02-16-2009 03:10 AM
Hello everybody, i have a problem: i dont know how to read data from the serial port.
i explain my goal: i have a mobile platform with 2 motored wheels, a nexys2 fpga board and a pc on my mobile platform. i have to create a connection between the pc and the fpga with the serial port. At the moment i can write on the serial (i use xil_printf) and i see all with hyperterminal on my pc but it isnt very important for my project. the problem is that i cant do the opposite, i dont know how to read data in the same way. The goall will be to elaborate data with the pc and send the velocity to the fpga via serial.
thanks for help and sorry for the bad english!
02-16-2009 03:59 PM
I have the same problem . I would like use rs232 with interrupt and i find this http://warp.rice.edu/trac/browser/trunk/EDK_Demos/UberDemo/demoapp2.c?rev=15 . I don't understand this function :
XIntc_RegisterHandler(XPAR_OPB_INTC_0_BASEADDR, XPAR_OPB_INTC_0_RS232_INTERRUPT_INTR, (XInterruptHandler)uart_int_handler, (void *) 0);.
What is XPAR_OPB_INTC_0_RS232_INTERRUPT_INTR?
02-17-2009 10:06 AM
rents85 wrote:I have the same problem . I would like use rs232 with interrupt and i find this http://warp.rice.edu/trac/browser/trunk/EDK_Demos/UberDemo/demoapp2.c?rev=15 . I don't understand this function :
XIntc_RegisterHandler(XPAR_OPB_INTC_0_BASEADDR, XPAR_OPB_INTC_0_RS232_INTERRUPT_INTR, (XInterruptHandler)uart_int_handler, (void *) 0);.
What is XPAR_OPB_INTC_0_RS232_INTERRUPT_INTR?
Look in xparameters.h.
-a
02-28-2009 09:49 AM
02-28-2009 09:54 AM
Hi all,
I'm a newbie and have a similar question. I am using a Spartan3A-1800A-DSP Board, and I want to communicate my board and PC. I'm trying to send data to RS232 by using a C program such as " printf"hello world" " , and hopefully can get it shown back on PC hyper-terminal.
Could anyone let me know how I can achieve this? Or some tutorials recommended will also be a help.Thank you in advance.
Kind regards,
tarzandavid
03-02-2009 01:44 AM
Hello tarzan,
I work with the same board, EDK, MicroBlaze and RS232.
Sending Data: There are two opportunities. You can configure the RS232 as Standard I/O. From this it follows that the methods "xil_printf" or "print" prints a string via Standard I/O (in this case RS232) to the console which is connected to the serial port of the PC (in your (windows) case: hyperterminal; for linux: minicom). Write "xil_printf("Hello World\n\r"); in your C-File and you get what you want to.
The second opportunity is to send a databuffer via RS232. Then there is no need to set it as Standard I/O. An example for sending a buffer, is delievered with EDK in its installation path (installationpath/EDK/sw/XilinxProcessorIPLib/drivers/uartlite_v_1_12_a/examples). You can find necessary functions in xuartlite.h.
Receivind Data: see examples and xuartlite.h.
Hope this helps.
Best regards, Robbi
03-02-2009 03:51 PM
hi robbi,
Thanks a lot for your suggestion, I'll try to do as what you told me. Really appreciated. :-)
tarzan
03-03-2009 09:21 AM
Hi together,
if you want to read data from a serial port that is connected to stdin,
you may follow this link :
http://forums.xilinx.com/xlnx/board/message?board.id=EDK&message.id=6717#M6717
--Ralf
03-04-2009 03:40 AM
Hi ralfcantnerbosch,
In the link you posted you mentioned "Hyperterminal sends each character as soon as you type it. It does not wait for the <RETURN> key. ", have you connected the board to PC under this circumstances?
tarzan
03-04-2009 03:59 AM
Hello tarzan,
are you working with EDK? If true, you can set the RS232 device as STD I/O in *.mss-file for your OS like:
BEGIN OS
PARAMETER OS_NAME = standalone
PARAMETER OS_VER = 2.00.a
PARAMETER PROC_INSTANCE = microblaze_0
PARAMETER STDIN = RS232_Uart_1
PARAMETER STDOUT = RS232_Uart_1
END
-> "Hyperterminal sends each character as soon as you type it. It does not wait for the <RETURN> key. "
I think this simply means how Hyperterminal works. If the serial connection is build up and you press a key on your keyboard (of the pc), the ASCII code of the key you pressed is sended via serial-interface. There is no need of pressing <RETURN> to confirm the sending.
I also have connected the Spartan-3A DSP Board to PC to communicate.
More questions?
Greetz Robbi
03-04-2009 07:30 AM
dedanan,
You would use a RecvByte or Recv function of the Uart driver.
The available functions for a driver are available in the API documentation. For example if you are using the xps_uartlite peripheral, then you would look at $XILINX_EDK/sw/XilinxProcessorIPLib/drivers/uartlite_v1_13_a/doc/html/api/index.html for the available functions in this driver.
Hope this helps...
03-04-2009 07:58 AM
Hello dedanan,
that's right what centaur10 says.
For receiving data via RS232 you need a RecvBuffer. Look after examples in:
$XILINX_EDK/sw/XilinxProcessorIPLib/drivers/uartlite_v1_13_a/examples
You can use it in polling mode or with interrupts. I am using it in polling mode.
First you have to initialize the UART interface:
XUartLite_Initialize(&UartLite, UARTLITE_DEVICE_ID);
Therfore you need a RecvBuffer of this type: Xuint8 RecvBuffer[16];
You can poll like this: while (XUartLite_Recv(&UartLite, RecvBuffer, 16) == 0);
This method returns the length of the received buffer. But be careful, data are sended in ASCII.
Best regards, Robbi
03-04-2009 08:35 AM
Hi tarzandavid,
if you skip the setvbuf() function in the example you will get what you want.
I have tested the stuff with Hyperterminal on WinXP.
BTW : if you want to receive a whole command line up to CR
you may try scanf(), but I never tested that.
But : with scanf() you do not have the ability to send back the
typed characters to the user. Depends on what you want and on the
settings of your terminal.
-- Ralf
03-07-2009 06:42 AM
Hi robbi,
Thanks for your advice, yes I am working with EDK and using spartan3a dsp 1800, just set the developing environment up couple of hours ago :P
What I'm doing right now is using the provided example files and following the instruction of Spartan3ADSP_MB_EXAMPLE_10_1.pdf, and I just met one problem. I have done the following part by following the example tutorial:
1. Connect the JTAG cable between board and PC
2. Connect the serial cable( RS232cable) between PC and P2 connector of the board
3. Apply power to the board
4. Start the HyperTerminal, set the Baud Rate to 9600, Data bits to 8 bits, Parity to None, Stop bits to 1 bit, and Flow control to None
5. Use iMPACT to download the bitstream
7. Invoke XMD and connect to the MicroBlaze Processor.
8. Download the Application to be tested
and then I followed the step 9 by running the software application, according to the tutorial, output of the TestApp Memory application and Peripheral application should appear on hyperterminal, but actually it didn't happen to mine.
I had COM1, COM2,COM3,COM8 in my PC. When I use 1,2,3 there are no response when typed "RUN" in XMD, and when I chose COM8 a notice saying" Another Program is Using the Selected Telephony...", so what's the matter with this issue and how can I get result shown in hyperterminal? Many thanks!
03-07-2009 12:00 PM - edited 03-07-2009 12:07 PM
Hi,
There is whole chapter (7) about UART in Spartan-3 devices in the book: "FPGA prototyping by VHDL Examples" by Pong P. Chu
I am attaching to console with the usage of screen tool.
Greetings, Mariusz
03-10-2009 09:19 AM
Hi guys,
I have fixed my problem and am able to successfully display results on hyperterminal now. The problem happened to my RS232 cable... I changed a new one then the problem was solved. Thanks for all your help :-)
Cheers,
tarzan