NONOS - Anyone have any sample code of receiving UART data

AgentSmithers
Posts: 195
Joined: Sat Apr 01, 2017 1:21 am
Contact:

NONOS - Anyone have any sample code of receiving UART data

Postby AgentSmithers » Wed Jan 24, 2018 3:26 pm

I've been googling around and couldn't find a straight forward example of just receiving a string through UART. Anyone have any sample code that fall's into uart0_rx_intr_handler.
Also os_printf also appears to stop printing once I run uart_config. Any way to keep that functionality while using UART?
Thanks everyone!

Her Mary
Posts: 537
Joined: Mon Oct 27, 2014 11:09 am

Re: NONOS - Anyone have any sample code of receiving UART data

Postby Her Mary » Thu Jan 25, 2018 5:36 pm

You should note that the code below will change your os_printf to output from UART1. Maybe your application mistakenly called it.

Code: Select all

    // install uart1 putc callback
    os_install_putc1((void *)uart1_write_char);//print output at UART1

AgentSmithers
Posts: 195
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: NONOS - Anyone have any sample code of receiving UART data

Postby AgentSmithers » Fri Jan 26, 2018 12:25 am

Her Majesty wrote:You should note that the code below will change your os_printf to output from UART1. Maybe your application mistakenly called it.

Code: Select all

    // install uart1 putc callback
    os_install_putc1((void *)uart1_write_char);//print output at UART1


Thanks!
I don't recall seeing this line but I'll take a look. Much appreciate. Thank you for your prompt response.

AgentSmithers
Posts: 195
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: NONOS - Anyone have any sample code of receiving UART data

Postby AgentSmithers » Tue Jan 30, 2018 1:53 pm

Yep, That fixed my Debug issue.

I wrote this, However if I can write the 16 bytes before the WDT everything works great. As soon as I write one byte without the other 15 I get a WDT. Anyone know why? Like I need to clear the interrupt or something?

Code: Select all

LOCAL void uart0_rx_intr_handler(void *para)
{
   char RcvChar[4];
    RcvMsgBuff *pRxBuff = (RcvMsgBuff *)para;

   if (UART_RXFIFO_FULL_INT_ST != (READ_PERI_REG(UART_INT_ST(UART0)) & UART_RXFIFO_FULL_INT_ST)) {
      return;
   }

   WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_FULL_INT_CLR);

   while (READ_PERI_REG(UART_STATUS(UART0)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S))
   {
      ETS_UART_INTR_DISABLE();
      RcvChar[0] = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF;      
      /* you can add your handle code below.*/
      gpio_output_set(0, (1 << 2), 0, 0);
      uart0_tx_buffer(RcvChar, 1);
       // Clear pending FIFO interrupts
      WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_TOUT_INT_CLR | UART_RXFIFO_FULL_INT_ST);
      ETS_UART_INTR_ENABLE();
   }
}

AgentSmithers
Posts: 195
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: NONOS - Anyone have any sample code of receiving UART data

Postby AgentSmithers » Tue Jan 30, 2018 2:13 pm

I fixed that by adjusting this line, it was set to 0x10 and not 0x01

WRITE_PERI_REG(UART_CONF1(uart_no), ((0x01 & UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S) | ((0x01 & UART_RX_FLOW_THRHD) << UART_RX_FLOW_THRHD_S) | UART_RX_FLOW_EN | (0x02 & UART_RX_TOUT_THRHD) << UART_RX_TOUT_THRHD_S | UART_RX_TOUT_EN);

Anyone have a link to the document for these flags? I don't see it in the Programming guide from Expressif.
Anyone know the line that adjust the parity on UART0?

EDIT:
I think i found the answer.
//WRITE_PERI_REG(UART_CONF0(uart_no), CALC_UARTMODE(UartDev.data_bits, UartDev.parity, UartDev.stop_bits));
WRITE_PERI_REG(UART_CONF0(uart_no), CALC_UARTMODE(UartDev.data_bits, NONE_BITS, UartDev.stop_bits));

So to see the current option set I assume I use GET_PERI_REG, as it stands using UartDev.data_bits set to the current value its set to with no changes correct?


AgentSmithers
Posts: 195
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: NONOS - Anyone have any sample code of receiving UART data

Postby AgentSmithers » Thu Feb 01, 2018 8:19 am



Ah that works!
Thanks. Give's me a good read.

Who is online

Users browsing this forum: No registered users and 117 guests