0

Adafruit Feather M4 Express SERCOM
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit Feather M4 Express SERCOM

by jeffLunar on Wed Jul 31, 2019 5:38 pm

Adafruit,

I am trying to create a new UART using the SERCOM functionality provided in the documentation. We are trying to create the new UART on pins A4 and A5. Here is the diagram that I am using to determine the SERCOM:PAD for the two pins.

Capture.PNG
Image of Adafruit Feater M4 Express
Capture.PNG (285.08 KiB) Viewed 78 times


According to the pin layout, A4 and A5 uses SERCOM0 on PADS 0 and 2 respectively. Following your guide here, I created the following code:

Code: Select all | TOGGLE FULL SIZE
#include <Arduino.h>   // required before wiring_private.h
#include "wiring_private.h" // pinPeripheral() function
 
Uart new_serial (&sercom0, 18, 19, SERCOM_RX_PAD_0, UART_TX_PAD_2);
void SERCOM0_Handler()
{
  new_serial.IrqHandler();
}
 
void setup() {
  Serial.begin(115200);
 
  new_serial.begin(115200);
 
  pinPeripheral(18, PIO_SERCOM);
  pinPeripheral(19, PIO_SERCOM);
}
 
uint8_t i=0;
void loop() {
  Serial.print(i);
  new_serial.write(i++);
  if (new_serial.available()) {
    Serial.print(" -> 0x"); Serial.print(new_serial.read(), HEX);
  }
  Serial.println();
 
  delay(10);
}


Running the code on the m4 express, we are receiving nothing from the new serial port that we are creating. We are at a brick wall trying to determine why this isn't working. Anyone have any suggestions?

Note:
I was able to change the new_serial to Serial1 with the same baud rate and was able to read the hex values correctly.

jeffLunar
 
Posts: 1
Joined: Wed Jul 31, 2019 5:26 pm

Re: Adafruit Feather M4 Express SERCOM

by adafruit_support_mike on Fri Aug 02, 2019 1:14 am

The SAMD51's SERCOMs are slightly different from the SAMD21's, covered in the tutorial you linked.

If you search the forum for 'SAMD51 SERCOM', you'll find threads discussing the issue, many of which have sample code:

search.php?st=0&sk=t&sd=d&sr=posts&keywords=samd51+sercom

adafruit_support_mike
 
Posts: 58856
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.