0

[SOLVED] Adding additional serial using SERCOM causes hang
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

[SOLVED] Adding additional serial using SERCOM causes hang

by btechnet on Thu May 30, 2019 2:15 pm

Using a Metro M4

And I need an additional serial port.
I setup SERCOM 5 to pins D2 and D3

Code: Select all | TOGGLE FULL SIZE
Uart Serial5(&sercom5, 2, 3, SERCOM_RX_PAD_1, UART_TX_PAD_0);

void SERCOM5_Handler()
{
  Serial5.IrqHandler();
}
void setup()
{
    pinPeripheral(2, PIO_SERCOM);
    pinPeripheral(3, PIO_SERCOM);
    Serial5.begin(9600)
}

void loop(){

 Serial5.println("running");
 delay(1000);
}



After hooking up a ftdi to those pins i get the first 2 letters "ru" and then the loop code execution stops.

Debugging going into a Dummy_Handler in cortex_handlers.c

I have tried this same code on arduino and vscode platformio with the same results.
I have also tried SERCOM 4 with the same results.

What am I missing here?

Adafruit datasheet for metro m4:
https://cdn-learn.adafruit.com/assets/assets/000/053/093/original/adafruit_products_schem.png?1524085993

Code example taken from Adafruit website:
https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports/creating-a-new-serial

-Anthony
Last edited by btechnet on Thu May 30, 2019 2:28 pm, edited 2 times in total.

btechnet
 
Posts: 4
Joined: Wed May 29, 2019 1:24 pm

Re: Adding additional serial using SERCOM causes hang when p

by btechnet on Thu May 30, 2019 2:27 pm

It appears the code example from here are not totally accurate:
https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports/creating-a-new-serial

There are multiple handlers for SERCOM's not just one.

The solution was to declare the handlers properly:

Code: Select all | TOGGLE FULL SIZE
void SERCOM5_0_Handler()
{
  Serial5.IrqHandler();
}
void SERCOM5_1_Handler()
{
  Serial5.IrqHandler();
}
void SERCOM5_2_Handler()
{
  Serial5.IrqHandler();
}
void SERCOM5_3_Handler()
{
  Serial5.IrqHandler();
}

btechnet
 
Posts: 4
Joined: Wed May 29, 2019 1:24 pm

Re: [SOLVED] Adding additional serial using SERCOM causes ha

by Ddahl08 on Fri Jun 14, 2019 5:40 pm

I am having the same issue although adding multipule Handler() did not seem to do anyting different. Any other solutions out there?

Ddahl08
 
Posts: 3
Joined: Mon Jan 23, 2017 4:57 pm

Please be positive and constructive with your questions and comments.