- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I require to send/receive a character through the rs232 port, however i only be able to receive character. I had problem with sending the character out. Below is my coding for sending and receiving. Please kindly provide me with advise/solution. Thanks void serial() { int a = 99; char c; c=IORD_ALTERA_AVALON_UART_RXDATA(UART_0_BASE); printf("%c",c); // result shown is correct IOWR_ALTERA_AVALON_UART_CONTROL(UART_0_BASE, 0x40); IOWR_ALTERA_AVALON_UART_TXDATA(UART_0_BASE,a);//NO CHARACTER DETECTED }Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello, I have made similar program.
I don't remember exactly what I did. the code was ------------------------------------------------------------------- void putUchar(unsigned char str) { IOWR_32DIRECT(H55UART_BASE,OFF_TXDATA ,str); usleep(UART_WAIT); // UART_WAIT is 1000 } ------------------------------------------------------------------- I think 1msec wait ( for 9600bps) is what you need. how is it?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Akira,
I had try to add on the usleep(1000) below my code, but yet no character is detect in my VB(visual basic) where I use to detect and send character. But anyhow, thanks for your advice.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how about doubting VB.
in some case you can not get characters when the character is not correct ASCII code. you should measure the signal TX. by oscilloscope or signaltapII. or, just send UART signal from NiosII to "the NiosII" by itself. good luck.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The easiest terminal emulator to use on windows (and probably linux) is putty. Testing with that will remove some of the unknowns.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks.... putty really save me out. Now i know is my VB problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi vincoldes!
i'm trying to finish my graduation project, for that i need to receive some text in my DE2 rs232 port and i'm using nios ii like u, i was wondering if you can help me here sending me your code? sorry but i'm really desperate =( hope to hear soon from you =)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi liscabello,
I found that we have 2 ways of doing it: 1. Using simple getc(fp) function where by pointer *fp is point to my uart. The code is something like this: FILE *fp fp = fopen ("/dev/uart_0", "r+"); while(fp) { getc(fp);read } fclose(fp) 2. Using IORD & IOWR for read and write.Example code as below: IOWR_ALTERA_AVALON_UART_TXDATA(UART_0_BASE,*(b+j)); for write IORD_ALTERA_AVALON_UART_TXDATA(UART_0_BASE,*(b+j)); for wirte You can refer to the handbook for further details. Sry that if I cant help much:)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank u vincoldes :) i'll try this as soon as i get home
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