Go Down

Topic: Multiple Additional SERCOM Mapping in MKR1000 (Read 126 times) previous topic - next topic

ttltoushan

Hello everyone,

I'm trying to map additional SERCOMs in MKR1000 for data acquisition with multiple serial UART sensors, but I can only get one additional UART working. Results of running the below code indicate that SERCOM3 is working properly, but SERCOM0 is not working. I have tried other SERCOMs according to the table of possible PAD to PIN mapping identified here, but none other than SERCOM3 worked.

Can anyone help out please with what I might be missing or doing incorrectly? Thank you and here is the code I am running to test out the SERCOM mapping (based on example here and MKR documentation of possible SERCOM mapping). For board wiring, I have a breadboard wire jumping pin 0 and pin 1 and another jumping A3 and A4 (pins 18 and 19, respectively).


Code: [Select]

#include <Arduino.h>
#include "wiring_private.h"
Uart mySerial1 (&sercom3, 0, 1, SERCOM_RX_PAD_1, UART_TX_PAD_0); // Create the new UART instance assigning it to pin 0 and 1
Uart mySerial2 (&sercom0, 18, 19, SERCOM_RX_PAD_1, UART_TX_PAD_0); // Create the new UART instance assigning it to pin 18 and 19

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  mySerial1.begin(9600);
  mySerial2.begin(9600);
  pinPeripheral(0, PIO_SERCOM); //Assign RX function to pin 0
  pinPeripheral(1, PIO_SERCOM); //Assign TX function to pin 1
  pinPeripheral(18, PIO_SERCOM); //Assign RX function to pin 18
  pinPeripheral(19, PIO_SERCOM); //Assign TX function to pin 19
}
int i = 0;
int j = 0;

void loop() {
  // print out the value you read on mySerial wired in loopback:
  mySerial1.write(i);
  i++;
  while (mySerial1.available()) {
    Serial.print("SERCOM3-");
    Serial.print(mySerial1.read());
  }
  Serial.println(".");
    delay(1000);

   mySerial2.write(j);
  j++;
  while (mySerial2.available()) {
    Serial.print("SERCOM0-");
    Serial.print(mySerial2.read());
  }
  Serial.println(".");
    delay(1000);
 
}

// Attach the interrupt handler to the SERCOM
void SERCOM3_Handler()
{
  mySerial1.IrqHandler();
}

void SERCOM0_Handler()
{
  mySerial2.IrqHandler();
}

Go Up