0

So I've got three boards that I'm using to test this (modified) code:

int sensor1Pin = A0;
int sensor2Pin = A1;
int sensor3Pin = A2;


float sensors[] = {0,0,0};

void setup(){
Serial.begin(9600);
}

void loop(){

sensors[0] = analogRead(sensor1Pin);
sensors[1] = analogRead(sensor2Pin);
sensors[2] = analogRead(sensor3Pin);

Serial.print(sensors[0]);
Serial.print(",");
Serial.print(sensors[1]);
Serial.print(",");
Serial.println(sensors[1]);
}

An Uno, a Feather M0, and an MKR1000. The code will only work on the Uno because it's AVR-based whereas the other two boards are SAMD. When running on a feather, you get this error:

/home/ghylama/Arduino/libraries/SoftwareSerial_master/SoftwareSerial.cpp:260:2: error: #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
     #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors

However, the resolution of the Uno is too low for my purposes (its DAC has a resolution of 10, whereas I need a resolution of 12, minimum). Are there any libraries/workarounds that I can use for this purpose?

I've tried SoftwareSerial, NeoSWSerial, and this one.

10
  • 1
    Sorry I'm confused, what exactly is the question? How to add Serial (/UART) ports to your Feather M0? Or about the DAC? You are using analogRead here though, which uses the ADC. Commented Feb 26, 2018 at 22:49
  • What has serial to do with DAC (ADC?) resolution?
    – gre_gor
    Commented Feb 26, 2018 at 22:49
  • Sorry if my wording was unclear but I've been at this for a while now so I've got tunnel vision. Running this code on a feather gives this error: Arduino/libraries/SoftwareSerial_master/SoftwareSerial.cpp:260:2:error: #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors Thing is, I can run this on an Uno without issues but I want it on a feather. The DAC has nothing to do with serial but that is my constraint. I need a library that does the same job as SoftwareSerial but for M0.
    – rddead
    Commented Feb 26, 2018 at 23:14
  • Why do you need software serial? An ARM part will typically have multiple hardware serial ports. Commented Feb 26, 2018 at 23:17
  • 1
    That has nothing to do with software serial, any serial implementation should work. Software serial is a hack to deal with the fact that the classic Arduino only has 1 port. Commented Feb 26, 2018 at 23:28

1 Answer 1

2

I will restate the problem as I have understood it: You want more Serial objects, aka more UART ports.

On your Adafruit Feather M0 with its SAMD21G18 Cortex-M0+ MCU, you have six SERCOM peripherals which you can arbitrarily configure to be a UART, I2C or SPI port. Each peripheral can have its connections routed to several different pins on the board. It is a very versatile piece of hardware.

Don't use a SoftwareSerial library made for AVR MCUs when you have the hardware. Adafruit's guide shows how you can reconfigure those SERCOMs to get additional Serial objects.

https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports?view=all#creating-a-new-serial

Not the answer you're looking for? Browse other questions tagged or ask your own question.