The Wio Terminal development board, from Seeed Studio, includes two grove ports:
The grove system, by Seeed Studio, allows you to create electronic projects in a modular way, offering different modules (sensors, control boards…) that can be interconnected thanks to a standard connector and ready-to-use libraries.
I tried to connect a GPS module (that makes use of UART communication) to the grove port on the right of my Wio Terminal but I found that it was not working.
After some investigation, I solved it by swapping the TX and RX signals (white and yellow wires) in the connector:
Here is the reason:
The standard pinout for grove connectors in UART mode is as follows:
If you take a look to the Wio Terminal schematics, you can associate the UART pins to the following signals:
- RX = A0/D0
- TX = A1/D1
Those signals correspond to two pins of the ATSAMD51P19A microcontroller:
- RX = A0/D0 = PB08/SERCOM4.0 (port 4 pad 0)
- TX = A1/D1 = PB09/SERCOM4.1 (port 4 pad 1)
The SAMD microcontrollers include a multiplexing feature, that is the possibility to connect internal peripherals (such as the one that handles UART communication) to different external pins. For a more detailed explanation, I leave you to this great tutorial by Sparkfun.
SeeedStudio designers decided to use SERCOM4 port for the grove port we’re working with.
From the microcontroller’s datasheet, you can read that TX signal can be routed only to pad 0:
while Seeed Studio connected that pad (pad 0, PB08 pin) to RX signal. This is the reason why to make UART grove modules work with the grove port on the right you have to swap the two signals.
In the end, here’s the code you need for configuring the port in Arduino:
static Uart Serial3(&sercom4, D1, D0, SERCOM_RX_PAD_1, UART_TX_PAD_0); void setup() { pinPeripheral(D0, PIO_SERCOM_ALT); pinPeripheral(D1, PIO_SERCOM_ALT); Serial3.begin(GPSBaud); } [...] void SERCOM4_0_Handler() { Serial3.IrqHandler(); } void SERCOM4_1_Handler() { Serial3.IrqHandler(); } void SERCOM4_2_Handler() { Serial3.IrqHandler(); } void SERCOM4_3_Handler() { Serial3.IrqHandler(); } |
1 Comment