Root cause
An Apollo3 chip has 2 uarts : UART0 and UART1. When a Serial instance is created ( in serial_api.c/ serial_init() ) based on the provided TX and RX pads, a lookup is performed to decide which UART to use. The lookup table is in PeripheralPins.c, part of the Mbed TARGET_Ambiq_Micro.
First, the Serial-instance is created (TX = 48 / RX= 49) and based on the lookup UART0 is assigned. Then the Serial1-instance is created (TX=39, RX =40), but now DUE TO AN ERROR IN THE LOOKUP TABLE, it is ALSO assigned to UART0. As a result BOTH Serial and Serial1 are assigned to UART0.
This ONLY happens on an Artemis Nano as that is using (TX=39, RX =40). The other boards with a Serial1 are using (TX=24, RX =25), which in the table can only be assigned to UART1
Solution
In the same lookup table (PeripheralPins.c) there are already entries to assign (TX=39, RX =40) to UART1. So by commenting out the lines in the TX and RX table for UART0.
Serial1 is now assigned to UART1 and then works as expected. Tested with a simple sketch, where I connected Putty on 9600 to Serial1 and used the Arduino IDE monitor on 115200.
The challenge
As the lookup table in PeripheralPins.c as part of the mbed pre-compiled archive a new archive needs to be created for the Artemis NANO. I have done that (based on 2.2.1) and have added that as a zip-file +instructions in the forum (https://forum.sparkfun.com/viewtopic.php?f=169&t=58621)
Edit: this is NOT a problem in V1.2.3 as there the UART to use is provided with the first parameter : Uart Serial1(1, 10, 9);
Problem description On an Artemis Nano the Serial1 and Serial do not work independent. They are ONE and the same.
As A result the SERIAL1 CAN NOT BE USED ON AN ARTEMIS NANO Also see topic https://forum.sparkfun.com/viewtopic.php?f=169&t=58621
Root cause An Apollo3 chip has 2 uarts : UART0 and UART1. When a Serial instance is created ( in serial_api.c/ serial_init() ) based on the provided TX and RX pads, a lookup is performed to decide which UART to use. The lookup table is in PeripheralPins.c, part of the Mbed TARGET_Ambiq_Micro.
First, the Serial-instance is created (TX = 48 / RX= 49) and based on the lookup UART0 is assigned. Then the Serial1-instance is created (TX=39, RX =40), but now DUE TO AN ERROR IN THE LOOKUP TABLE, it is ALSO assigned to UART0. As a result BOTH Serial and Serial1 are assigned to UART0.
This ONLY happens on an Artemis Nano as that is using (TX=39, RX =40). The other boards with a Serial1 are using (TX=24, RX =25), which in the table can only be assigned to UART1
Solution
In the same lookup table (PeripheralPins.c) there are already entries to assign (TX=39, RX =40) to UART1. So by commenting out the lines in the TX and RX table for UART0.
Serial1 is now assigned to UART1 and then works as expected. Tested with a simple sketch, where I connected Putty on 9600 to Serial1 and used the Arduino IDE monitor on 115200.
The challenge As the lookup table in PeripheralPins.c as part of the mbed pre-compiled archive a new archive needs to be created for the Artemis NANO. I have done that (based on 2.2.1) and have added that as a zip-file +instructions in the forum (https://forum.sparkfun.com/viewtopic.php?f=169&t=58621)
Edit: this is NOT a problem in V1.2.3 as there the UART to use is provided with the first parameter : Uart Serial1(1, 10, 9);
regards, Paulvha