To obtain highest possible network speed with our Challenger RP2040 WiFi/BLE board we need to switch from using the standard UART to using RP2040 Programmable IO (PIO) Uarts. These allow for higher transfer speeds and more consistent baud rates than the standard UART wich will make it easier to reach the maximum network speed.
/*
* PIO Uart test program for the Challenger boards.
*
* This program shows how to replace internal UART1 (Serial2) with a PIO
* uart. This is usefull in scenarios where the internal UART together
* with its CTS/RTS pins are needed externally.
*/
#include <ChallengerWiFi.h>
#include <SerialPIO.h>
SerialPIO PIOUart(PIN_SERIAL2_TX, PIN_SERIAL2_RX);
void setup() {
Serial.begin(115200);
while (!Serial)
delay(10);
Serial.println(F("Test started !"));
// Assign new PIOUart port to be used for the ESP.
Challenger2040WiFi.setSerial(&PIOUart);
if (Challenger2040WiFi.reset()) {
Serial.println(F("WiFi Chip reset OK !"));
} else {
Serial.println(F("Could not reset WiFi chip !"));
while(1);
}
Serial.println(F("Test ended !"));
}
void loop() {
// put your main code here, to run repeatedly:
}
The source code above shows how to instantiate the PIO Uart properly and how to use the setSerial() function to replace the hardware Uart with our newly created PIO Uart. The old hardware Uart is released by this function and can now be used for other purposes by reassigning the serial pins.
Check out our example Measure network speed on ESP devices on how to use it in real life and how it impacts the system.
0 Comments for “Using RP2040 PIO Uarts with the WiFi module”