A large amount of internal memory RAM with UART driver use in a TASK

lucilla2002
Posts: 5
Joined: Thu Sep 15, 2022 3:14 pm

A large amount of internal memory RAM with UART driver use in a TASK

Postby lucilla2002 » Wed May 22, 2024 12:09 pm

Hi !!
I'm using v5.2-dev-3903-g66992aca7a-dirty on ESP32 WROVER E with 8M FLASH and 8M SPIRAM
I created a TASK that uses a UART driver:

xTaskCreatePinnedToCore(&board_task, "board_task", 4096, NULL, 5, NULL, 0);

void board_task(void* pvParameter)
{
uint32_t length;

const uart_config_t uart_config = {
.baud_rate = 57600,
.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,
};

uart_driver_install(UART_BOARD_NUMBER, UART_RX_BOARD_BUFF_DIM, 0, 0, NULL, 0);
uart_param_config(UART_BOARD_NUMBER, &uart_config);
uart_set_pin(UART_BOARD_NUMBER, UART_BOARD_TX, UART_BOARD_RX, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);

buart->rx_data = heap_caps_calloc(UART_RX_BOARD_BUFF_DIM, 1, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
buart->tx_data = heap_caps_calloc(UART_TX_BOARD_BUFF_DIM, 1, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
buart->uart_speed = 0;

for (;;)
{
send_frame();
length = receive_frame();
BoardCom_ReceivedFrame(buart->rx_data, length);
vTaskDelay(3/ portTICK_PERIOD_MS);
}
}

Before to call xTaskCreatePinnedToCore the internal RAM is this:

heap_caps_get_free_size: 250631
heap_caps_get_minimum_free_size: 250047
heap_caps_get_largest_free_block: 118784

after created the TASK is:

heap_caps_get_free_size: 211531
heap_caps_get_minimum_free_size: 211439
heap_caps_get_largest_free_block: 110592

I expected about 4K of TASK STACK SIZE ...not about 30K!
How is it possible?

lucilla2002
Posts: 5
Joined: Thu Sep 15, 2022 3:14 pm

Re: A large amount of internal memory RAM with UART driver use in a TASK

Postby lucilla2002 » Wed May 22, 2024 12:12 pm

I tryed the same with 4.1 IDF version and I have this result that seems better

Before TASK crreation:
heap_caps_get_free_size: 196315
heap_caps_get_minimum_free_size: 196215
heap_caps_get_largest_free_block: 110592

After TASK creation:
I (11512) : Dopo BOARD INIT
heap_caps_get_free_size: 188911
heap_caps_get_minimum_free_size: 188811
heap_caps_get_largest_free_block: 110592

MicroController
Posts: 1705
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: A large amount of internal memory RAM with UART driver use in a TASK

Postby MicroController » Wed May 22, 2024 3:05 pm

lucilla2002 wrote:
Wed May 22, 2024 12:09 pm
I expected about 4K of TASK STACK SIZE ...not about 30K!
How is it possible?
uart_driver_install(...) and heap_caps_calloc(...) inside board_task(), for instance.

Who is online

Users browsing this forum: No registered users and 84 guests