at_register_uart_rx_intr(user_uart_rx_intr);

CCP1CON
Posts: 10
Joined: Fri Oct 23, 2015 4:18 am

at_register_uart_rx_intr(user_uart_rx_intr);

Postby CCP1CON » Tue Nov 24, 2015 7:34 pm

Hello Folks,

I use at_register_uart_rx_intr(user_uart_rx_intr); to register a UART0 RX interrupt function.
I’m unsure about the calls to this function.
Let’s assume the other controller, connected to UART0, sends 32 bytes.
How often user_uart_rx_intr() will be called?

32 times once for each char?
Only once delivering 32 bytes in a bunch?
Or it is unpredictable?

Thanks for your time.

CCP1CON
Posts: 10
Joined: Fri Oct 23, 2015 4:18 am

Re: at_register_uart_rx_intr(user_uart_rx_intr);

Postby CCP1CON » Sat Nov 28, 2015 4:46 pm

Hello it's me.

I figured it out myself.
You will not get any interrupt unless the last two bytes are 0x10, 0x13 (LF and CR) (or the UART0 buffer over runs at 100 bytes or so).
Strange, my intentionn is not to send a AT command neither a String.
So why is this?

tve
Posts: 123
Joined: Sun Feb 15, 2015 4:33 pm

Re: at_register_uart_rx_intr(user_uart_rx_intr);

Postby tve » Sun Nov 29, 2015 5:21 pm

Your test is faulty...
You can get an interrupt when the fifo reaches a fill level you set or when there are characters in the fifo and nothing new has been received in a time period you set.

CCP1CON
Posts: 10
Joined: Fri Oct 23, 2015 4:18 am

Re: at_register_uart_rx_intr(user_uart_rx_intr);

Postby CCP1CON » Sun Nov 29, 2015 5:37 pm

Possibly... tanks ... but it works. :D

How can I set/read the FIFO fill level and the mentioned time period?
What are the default values?
Or where can I find these information?

Thanks

CCP1CON
Posts: 10
Joined: Fri Oct 23, 2015 4:18 am

Re: at_register_uart_rx_intr(user_uart_rx_intr);

Postby CCP1CON » Tue Dec 01, 2015 4:16 am

I think I found something related to the UART configuration:

WRITE_PERI_REG(UART_CONF1(0),
((0x01 & UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S) |
((0x01 & UART_RX_FLOW_THRHD) << UART_RX_FLOW_THRHD_S) |
UART_RX_FLOW_EN);

Is there a description of all these registers and definitions?

Thanks in advance.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: at_register_uart_rx_intr(user_uart_rx_intr);

Postby ESP_Faye » Tue Dec 01, 2015 3:15 pm


CCP1CON
Posts: 10
Joined: Fri Oct 23, 2015 4:18 am

Re: at_register_uart_rx_intr(user_uart_rx_intr);

Postby CCP1CON » Thu Dec 03, 2015 4:09 am

Thanks Fay, this helped.

I found that a RX full threshold would not fit to my needs because I do not have a fix packet length.
Therefore I go for a TOUT threshold.

In 8E-ESP8266__Interface_UART__EN_v0.2.pdf manual it says:
„The unit of TOUT threshold value is equal to the time of transmitting 8 byte data via UART, almost a byte.“

I guess it must read … transmitting 8 bit …

Because my max packet length is 66 bytes and stop bit and parity is enable I should set the threshold to 82?
66 * 10 (8+2) = 660 bits div 8 = 82
To have a little safety gap I will set it to 85.

Is my math correct?
And my code would be something like this:

Code: Select all

WRITE_PERI_REG(0x60000024, 85 << UART_RX_TOUT_THRHD_S | UART_RX_TOUT_EN);
SET_PERI_REG_MASK(0x6000000C, UART_RXFIFO_TOUT_INT_ENA);


Thanks

tve
Posts: 123
Joined: Sun Feb 15, 2015 4:33 pm

Re: at_register_uart_rx_intr(user_uart_rx_intr);

Postby tve » Sat Dec 05, 2015 11:50 am

You're misunderstanding TOUT. A TOUT value of N means: "if you have not received any new character in N time units then an interrupt is fired. A time unit is the time it takes to receive 8 bits."

CCP1CON
Posts: 10
Joined: Fri Oct 23, 2015 4:18 am

Re: at_register_uart_rx_intr(user_uart_rx_intr);

Postby CCP1CON » Wed Dec 09, 2015 1:23 am

Thank you tve.

I have set TOUT to 5 (5x8=40; approx. 4 Byte) and it works ok.

There is one more question.
ESP does not receive the first byte. It always shows a zero instead. I did search a bit and think that ESP seems to expect a Break signal. Is there a way to configure ESP such that it will immediately capture the first byte?
Or is there another reason?

Who is online

Users browsing this forum: No registered users and 137 guests