[riot-devel] Working on port to SODAQ Autonomo (SAMD21)

Kees Bakker kees at sodaq.com
Tue Jun 14 20:59:06 CEST 2016

As promissed ...

The final change to make it work was selecting the correct "mux". There
were a few hardcoded things in
* boards/samr21-xpro/include/periph_conf.h
* cpu/samd21/periph/uart.c

SAMR21_XPRO has the first serial connected to:
   RX - PA5
   TX - PA4
static const uart_conf_t uart_config[] = {
     /* device, RX pin, TX pin, mux */

My SODAQ Autonomo board has the first serial connected to:
   RX - PA9
   TX - PA10
static const uart_conf_t uart_config[] = {
     /* device, RX pin, TX pin, mux */

Is that all? No, welcome to the SERCOM world of ARM Cortex M0.
In cpu/sam???/periph/uart.c some changes are needed too. In the next 
diff, the samr21
is the "old" samd21.

--- cpu/samd21/periph/uart.c    2016-06-13 22:41:15.358773522 +0200
+++ cpu/samr21/periph/uart.c    2016-05-31 19:57:02.788554067 +0200
@@ -86,10 +86,9 @@
      /* reset the UART device */
      while (dev->SYNCBUSY.reg & SERCOM_USART_SYNCBUSY_SWRST) {}
-    /* set asynchronous mode w/o parity, LSB first, PAD2 to TX, PAD1 to 
RX, sample rate 16x and
+    /* set asynchronous mode w/o parity, LSB first, PAD0 to TX, PAD1 to 
RX and
       * use internal clock */
-                      SERCOM_USART_CTRLA_TXPO(0x1) |
                        SERCOM_USART_CTRLA_RXPO(0x1) |
                        SERCOM_USART_CTRLA_SAMPR(0x1) |

Notice the TXPO and RXPO. These indicate which "pads" the pin can use on 
a certain SERCOM.
So, what we can learn from this is that we need to expand uart_conf_t. 
We need PAD configuration
too. (BTW, Arduino Core is doing similar things.)

Was this a TL;DR? Sorry about it then.
-- Kees

On 13-06-16 23:28, Peter Kietzmann wrote:
> Congrats! Looking forward to hear the trick that did it :-).
> Good night
> Peter
> Am 13.06.2016 um 23:21 schrieb Kees Bakker:
>> On 13-06-16 20:55, Kees Bakker wrote:
>>> That is more or less already what I did. I filled in uart_config[]
>>> with two devices
>>> and I have a serial line connect to my PC. This configuration works
>>> with the Arduino
>>> setup. But not yet with RIOT.
>> I almost gave up ..., but then ...
>> �main(): This is RIOT! (Version:
>> 2016.07-devel-191-g42127-rapper-sodaq-autonomo)
>> Hello World!
>> You are running RIOT on a(n) sodaq-autonomo board.
>> This board features a(n) samd21 MCU.
>> Yeah, it's working. Well, hello world is.
>> (( It's getting too late now. I'll explain later this week what was
>> needed to make it work. ))

Kees Bakker
M. 0031617737165

More information about the devel mailing list