Skip to content

Commit e91da7b

Browse files
committed
UART2: Reduce FIFO threshold, pin to core 1.
1 parent 047f505 commit e91da7b

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -327,17 +327,27 @@ void beginUART2()
327327
{
328328
rBuffer = (uint8_t*)malloc(settings.gnssHandlerBufferSize);
329329

330-
if (pinUART2TaskHandle == NULL) xTaskCreatePinnedToCore(
331-
pinUART2Task,
332-
"UARTStart", //Just for humans
333-
2000, //Stack Size
334-
NULL, //Task input parameter
335-
0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest
336-
&pinUART2TaskHandle, //Task handle
337-
0); //Core where task should run, 0=core, 1=Arduino
330+
//TODO - For testing, pin to core 1
331+
serialGNSS.setRxBufferSize(settings.uartReceiveBufferSize);
332+
serialGNSS.setTimeout(settings.serialTimeoutGNSS);
333+
serialGNSS.begin(settings.dataPortBaud); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.
338334

339-
while (uart2pinned == false) //Wait for task to run once
340-
delay(1);
335+
//Reduce threshold value above which RX FIFO full interrupt is generated
336+
//Allows more time between when the UART interrupt occurs and when the FIFO buffer overruns
337+
//serialGNSS.setRxFIFOFull(50); //Available in >v2.0.5
338+
uart_set_rx_full_threshold(2, 50); //uart_num, threshold
339+
340+
// if (pinUART2TaskHandle == NULL) xTaskCreatePinnedToCore(
341+
// pinUART2Task,
342+
// "UARTStart", //Just for humans
343+
// 2000, //Stack Size
344+
// NULL, //Task input parameter
345+
// 0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest
346+
// &pinUART2TaskHandle, //Task handle
347+
// 0); //Core where task should run, 0=core, 1=Arduino
348+
//
349+
// while (uart2pinned == false) //Wait for task to run once
350+
// delay(1);
341351
}
342352

343353
//Assign UART2 interrupts to the core 0. See: https://github.com/espressif/arduino-esp32/issues/3386
@@ -347,6 +357,11 @@ void pinUART2Task( void *pvParameters )
347357
serialGNSS.setTimeout(settings.serialTimeoutGNSS);
348358
serialGNSS.begin(settings.dataPortBaud); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.
349359

360+
//Reduce threshold value above which RX FIFO full interrupt is generated
361+
//Allows more time between when the UART interrupt occurs and when the FIFO buffer overruns
362+
//serialGNSS.setRxFIFOFull(50); //Available in >v2.0.5
363+
uart_set_rx_full_threshold(2, 50); //uart_num, threshold
364+
350365
uart2pinned = true;
351366

352367
vTaskDelete( NULL ); //Delete task once it has run once

0 commit comments

Comments
 (0)