UART kills

hanzzz
Posts: 1
Joined: Fri Feb 21, 2020 2:17 pm

UART kills

Postby hanzzz » Fri Feb 21, 2020 2:43 pm

I have a question related with the esp32 UART interface and FreeRTOS tasks. Here is my code:

Code: Select all

	#define U1TXD                     10
	#define U1RXD                     9
	const int uart_num = UART_NUM_2;
     	const int uart_buffer_size = (1024 * 2);

        gpio_pad_select_gpio(LED);
        gpio_set_direction(LED, GPIO_MODE_OUTPUT);
        TaskHandle_t ledHandle = NULL;
        QueueHandle_t uart_queue;


        void ledTask(void *pvParameters)
        {
            int led = 0;
            for(;;)
            {
                ESP_LOGI("ledTask", "blink");
                gpio_set_level(LED, !led);
                led = !led;
                vTaskDelay(100);
            }
        }


        void UART_init()
        {
            // uart config
            uart_config_t uart_config = {
                .baud_rate = 9600,
                .data_bits = UART_DATA_8_BITS,
                .parity = UART_PARITY_DISABLE,
                .stop_bits = UART_STOP_BITS_1,
                .flow_ctrl = UART_HW_FLOWCTRL_DISABLE
            };

            ESP_ERROR_CHECK(uart_param_config(uart_num, &uart_config));
            ESP_ERROR_CHECK(uart_set_pin(uart_num, U1TXD, U1RXD, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
            ESP_ERROR_CHECK(uart_driver_install(uart_num, uart_buffer_size, uart_buffer_size, 10, &uart_queue, 		ESP_INTR_FLAG_LEVEL1));
        }


        xTaskCreate(ledTask, "led_task", 2048, NULL, configMAX_PRIORITIES , &ledHandle);
        vTaskDelay(200);
                    
        UART_init();
        
I create a tasks that blinks a led every 100 ticks. After that I execute a function that will initialize an UART interface, but when the UART_init function is completed my led stops blinking?! I have debugged this issue for hours, but I couldn't find the problem. Can maybe someone point me in the right direction?

Thanks in advance!!

boarchuz
Posts: 566
Joined: Tue Aug 21, 2018 5:28 am

Re: UART kills

Postby boarchuz » Fri Feb 21, 2020 3:17 pm

Try (configMAX_PRIORITIES - 1)

Who is online

Users browsing this forum: Majestic-12 [Bot] and 285 guests