I'm having some problems with the RX of the Uart.
What i want to do: I want to detect a series of five 0x55 on a RS485-bus and trigger an interrupt. My data packets for testing look like this:
Code: Select all
0x55|0x55|0x55|0x55|0x55|0x10|0x20|0x30|0x40|0xFF
Code: Select all
#include "CT10_Transceive.h"
void CT10_Uart_Init()
{
// Set HW Uart
uart_config_t uart_config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 10,
};
ESP_ERROR_CHECK(uart_param_config(UART_NUM_2, &uart_config));
// Set UART pins(TX: IO25, RX: IO26, RTS: IO18, CTS: IO19)
ESP_ERROR_CHECK(uart_set_pin(UART_NUM_2, 25, 26, 27, UART_PIN_NO_CHANGE));
// Install UART driver using an event queue here
ESP_ERROR_CHECK(uart_driver_install(UART_NUM_2, 129, 129, NULL, NULL, NULL));
//Set Pattern ISR
//Detect the 0x55 series of five
//30us timeout, 1,5ms Pre_idle, 1ms post idle
ESP_ERROR_CHECK(uart_isr_free(UART_NUM_2));
ESP_ERROR_CHECK(uart_isr_register(UART_NUM_2, pattern_isr, NULL, ESP_INTR_FLAG_IRAM, NULL))
ESP_ERROR_CHECK(uart_enable_pattern_det_intr(UART_NUM_2, 0x55, 5, 2400, 80000, 120000));
// Set Halfduplex Mode
ESP_ERROR_CHECK(uart_set_mode(UART_NUM_2, UART_MODE_RS485_HALF_DUPLEX));
}
static void IRAM_ATTR pattern_isr(void *para)
{
//Clear Interrupt and send message
uart_clear_intr_status(UART_NUM_2,UART_AT_CMD_CHAR_DET_INT_CLR);
uart_write_bytes(UART_NUM_2,(const char*) "OK" , 2);
}
Code: Select all
#ifndef CT10_Trans_H
#define CT10_Trans_H
#include <stdio.h>
#include "driver/timer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "driver/uart.h"
#include "esp_log.h"
//function constructors
void CT10_Uart_Init();
static void IRAM_ATTR pattern_isr(void *para);
#endif
Code: Select all
#include <stdio.h>
#include "esp_types.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "soc/timer_group_struct.h"
#include "driver/periph_ctrl.h"
#include "driver/timer.h"
#include "HW_Timers2.h"
#include "CT10_Transceive.h"
void app_main()
{
//Uart init
CT10_Uart_Init();
}
Code: Select all
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)
Core 0 register dump:
PC : 0x40087516 PS : 0x00060234 A0 : 0x80086aee A1 : 0x3ffb04d0
A2 : 0x3ffb6e20 A3 : 0x3ffb55b0 A4 : 0x00060221 A5 : 0x00000001
A6 : 0x00060221 A7 : 0x00000000 A8 : 0x3ffb55b0 A9 : 0x3ffb55b0
A10 : 0x00000019 A11 : 0x00000019 A12 : 0x40082060 A13 : 0x00000001
A14 : 0x00060223 A15 : 0x3ffb0cf0 SAR : 0x0000001d EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
Core 0 was running in ISR context:
EPC1 : 0x40086107 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x40087516
Backtrace: 0x40087516:0x3ffb04d0 0x40086aeb:0x3ffb04f0 0x400858e4:0x3ffb0510 0x400849bb:0x3ffb0550 0x400e2ad2:0x3ffb0580 0x400e345d:0x3ffb05c0 0x4008205d:0x3ffb05f0 0x40082a8d:0x3ffb0610 0x4008205d:0x00000000
Core 1 register dump:
PC : 0x40084edb PS : 0x00060034 A0 : 0x80085e4d A1 : 0x3ffb5b10
A2 : 0x3ffb1070 A3 : 0x3f4035a0 A4 : 0x00000014 A5 : 0x3ffb0bd0
A6 : 0x3ffb0c18 A7 : 0x00000001 A8 : 0x0000cdcd A9 : 0x0000abab
A10 : 0x00060023 A11 : 0xb33fffff A12 : 0x0000cdcd A13 : 0x3ffb0ba0
A14 : 0x00000008 A15 : 0x00000001 SAR : 0x00000018 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x40084edb:0x3ffb5b10 0x40085e4a:0x3ffb5b30 0x40085090:0x3ffb5b50 0x40085042:0xa5a5a5a5
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x1e (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6184
load:0x40078000,len:10168
load:0x40080400,len:6632
entry 0x40080764
So.....after two days of trying....im asking you for help guys
Greetings from Germany,
Florian