UART Interrupt. Porting from STM32 to ESP 32

waterfox
Posts: 20
Joined: Sun Mar 22, 2020 10:19 pm

UART Interrupt. Porting from STM32 to ESP 32

Postby waterfox » Mon May 04, 2020 8:28 pm

Hi,
I'm in the progress of porting BACnet MSTP from STM32 to ESP32. (The STM32 is programmed by Steve Karg https://github.com/bacnet-stack/bacnet-stack).

Now I'm able to compile the Code with the IDF 4.1. And it kind of runs on the ESP32.
At the moment I'm struggling with the following part. Or with other words I think that's the reason why the ESP is not able to receive data.
For the STM32 it looks like this:

Code: Select all

void USART2_IRQHandler(void)
{
    uint8_t data_byte;

    if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) {
        /* Read one byte from the receive data register */
        data_byte = USART_ReceiveData(USART2);
        (void)FIFO_Put(&Receive_Buffer, data_byte);
    }
}

I've tried to solve the Problem as follows:

Code: Select all

{
   uint8_t data_byte;
   uart_read_bytes(UART_NUM_1, &data_byte, 1, 100 / portTICK_RATE_MS); 
   (void)FIFO_Put(&Receive_Buffer, data_byte);
   }
I thought that uart_read_bytes already trigger an interrupt. But maybe that's not enough?
How do I trigger the Interrupt correct?
I also put both files I compared into the attachments.

If someone is more interested in helping me with the backnet-stack, here is my git where I have the actual build: https://github.com/waterfox207/bacnet-s ... esp32_mstp


hope that someone can help me. :-)
Attachments
rs485stm32.c
(13.09 KiB) Downloaded 514 times
rs485-esp32.c
(12.66 KiB) Downloaded 456 times

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: UART Interrupt. Porting from STM32 to ESP 32

Postby ESP_Sprite » Tue May 05, 2020 7:30 am

It might be easier to remove the entire FIFO logic, as the ESP32 UART driver already integrates an interrupt handler and FIFO.

waterfox
Posts: 20
Joined: Sun Mar 22, 2020 10:19 pm

Re: UART Interrupt. Porting from STM32 to ESP 32

Postby waterfox » Wed May 06, 2020 5:45 pm

Thank you I will give this a try :-)

FluxGS
Posts: 29
Joined: Sun Mar 18, 2018 7:01 am

Re: UART Interrupt. Porting from STM32 to ESP 32

Postby FluxGS » Tue Aug 01, 2023 5:07 pm

How did your port turn out?
I have an up coming project that requires a BACnet RS485 MS/TP slave feature to report a temperature.

waterfox
Posts: 20
Joined: Sun Mar 22, 2020 10:19 pm

Re: UART Interrupt. Porting from STM32 to ESP 32

Postby waterfox » Wed Aug 02, 2023 6:12 am

I was never able to finish the port.

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 122 guests