Ok so I partially fixed the issue and now I can read the letter "p" that is being transmitting from a pic microcontroller. but I'm having this Guru meditation error after the buffer get full. I tried to flush after the loop but it didn't help. The code is below :
Code: Select all
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_log.h"
#include "driver/uart.h"
#include "string.h"
#include "driver/gpio.h"
static const int RX_BUF_SIZE = 1024;
#define TXD_PIN (GPIO_NUM_4)
#define RXD_PIN (GPIO_NUM_5)
#define TXD_PIN (GPIO_NUM_18)
#define RXD_PIN (GPIO_NUM_19)
void init(void) {
const 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,
//.source_clk = UART_SCLK_APB,
};
// We won't use a buffer for sending data.
uart_driver_install(UART_NUM_1, RX_BUF_SIZE * 2, 0, 0, NULL, 0);
uart_param_config(UART_NUM_1, &uart_config);
uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
}
static void rx_task(void *arg)
{
static const char *RX_TASK_TAG = "RX_TASK";
esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO);
uint8_t* data = (uint8_t*) malloc(RX_BUF_SIZE+1);
while (1) {
const int rxBytes = uart_read_bytes(UART_NUM_1, data, RX_BUF_SIZE, 1000 / portTICK_RATE_MS);
if (rxBytes > 0) {
data[rxBytes] = 0;
ESP_LOGI(RX_TASK_TAG, "Read %d bytes: '%s'", rxBytes, data);
//vTaskDelay(500);
ESP_LOG_BUFFER_HEXDUMP(RX_TASK_TAG, data, rxBytes, ESP_LOG_INFO);
}
}
free(data);
}
void app_main(void)
{
init();
xTaskCreate(rx_task, "uart_echo_task", 1024, NULL, 10, NULL);
}
The error is :
I (518) RX_TASK: Read 1024 bytes: 'ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppGuru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Core 0 register dump:
PC : 0x70707070 PS : 0x00050033 A0 : 0x70707070 A1 : 0x3ffb7150
A2 : 0x70707070 A3 : 0x70707070 A4 : 0x70707070 A5 : 0x70707070
A6 : 0x70707070 A7 : 0x70707070 A8 : 0x70707070 A9 : 0x70707070
A10 : 0x70707070 A11 : 0x70707070 A12 : 0x70707070 A13 : 0x70707070
A14 : 0x70707070 A15 : 0x3ffb7520 SAR : 0x00000004 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffeff
Backtrace:0x7070706d:0x3ffb7150 |<-CORRUPTED
ELF file SHA256: fe7687a6cb18dc92
Rebooting...