- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi
i am having problems in wrting a C function that can read data streams from the UART and returning it to a buffer . can some body help me out with this.. byeLink Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by sandybhai@Oct 15 2006, 04:08 PM hi
i am having problems in wrting a c function that can read data streams from the uart and returning it to a buffer .
can some body help me out with this..
bye
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=18707)
--- quote end ---
--- Quote End --- Hey Sandybhai, I suggest to receive data coming from the UART under interrupt. This means that your program will jump to the interrupt function (which will receive the uart data) from RX data is received. You can then place the data into a buffer (an array string) so you can handle the data afterwards. Here is an example code: void UartReceiver1(void * content,alt_u32 id) { // get the uart data unsigned char * UartData = (unsigned char*)(UART1_BASE); // UART1_BASE is defined in system.h } } Setting up the interrupt: enter this into your main code // UART1 interrupt routine declaration alt_irq_register(UART1_IRQ,NULL,UartReceiver1); IOWR_ALTERA_AVALON_UART_CONTROL(UART1_BASE, 0x80); This is an easy way to receive UART data without the need of specific NIOS instructions for UART handling. Kind regards Karel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by karel van haver+oct 18 2006, 01:27 pm--><div class='quotetop'>quote (karel van haver @ oct 18 2006, 01:27 pm)</div>
--- quote start ---
<!--quotebegin-sandybhai@Oct 15 2006, 04:08 PM hi
i am having problems in wrting a c function that can read data streams from the uart and returning it to a buffer .
can some body help me out with this..
bye
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=18707)
--- quote end ---
--- Quote End --- Hey Sandybhai, I suggest to receive data coming from the UART under interrupt. This means that your program will jump to the interrupt function (which will receive the uart data) from RX data is received. You can then place the data into a buffer (an array string) so you can handle the data afterwards. Here is an example code: void UartReceiver1(void * content,alt_u32 id) { // get the uart data unsigned char * UartData = (unsigned char*)(UART1_BASE); // UART1_BASE is defined in system.h String[i] = *UartData; i++; } } Setting up the interrupt: enter this into your main code // UART1 interrupt routine declaration alt_irq_register(UART1_IRQ,NULL,UartReceiver1); IOWR_ALTERA_AVALON_UART_CONTROL(UART1_BASE, 0x80); This is an easy way to receive UART data without the need of specific NIOS instructions for UART handling. Kind regards Karel <div align='right'><{post_snapback}> (index.php?act=findpost&pid=18775)</div> [/b] --- Quote End ---
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assume your system is based on Nios II:
>map your UART into stdin and stdout >then check with stdio command then you can verify hardware implementation. After doing that you can play with HAL driver.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by legendbb@Nov 3 2006, 07:15 AM assume your system is based on nios ii:
>map your uart into stdin and stdout
>then check with stdio command then you can verify hardware implementation.
after doing that you can play with hal driver.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=19145)
--- quote end ---
--- Quote End --- Hi ledendbb, Could you please elaborate how to map UART into stdin and stdout so that stdio command can be used? Thanks, yjp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by yanjiapan+nov 5 2006, 05:40 pm--><div class='quotetop'>quote (yanjiapan @ nov 5 2006, 05:40 pm)</div>
--- quote start ---
<!--quotebegin-legendbb@Nov 3 2006, 07:15 AM assume your system is based on nios ii:
>map your uart into stdin and stdout
>then check with stdio command then you can verify hardware implementation.
after doing that you can play with hal driver.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=19145)
--- quote end ---
--- Quote End --- Hi ledendbb, Could you please elaborate how to map UART into stdin and stdout so that stdio command can be used? Thanks, yjp <div align='right'><{post_snapback}> (index.php?act=findpost&pid=19195)</div> [/b] --- Quote End --- Just take a look at the System Library properties page and you'll see the option there. Alternately, you can modify the system.stf file (in the syslib project's top-level directory) to point stdin/stdout/stderr to whichever device you'd like to use. The system.stf is mostly used for holding persistence for GUI settings on the syslib properties page. Cheers, - slacker
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