Hi, I followed the official arduino tutorial to create an extra UART TX/RX port and for my MKRzero and modified it slightly to produce:
/*
AnalogReadSerial on new UART placed on pins 1 and 0
Reads an analog input on pin A0, prints the result to the serial monitor.
Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
Attach the center pin of a potentiometer to pin A0, and the outside pins to +3.3V and ground.
Short together pin 1 and pin 0 with a wire jumper
Created 20 Jun 2016
by
Arturo Guadalupi <a.guadalupi@arduino.cc>
This example code is in the public domain.
*/
#include <Arduino.h>
#include "wiring_private.h"
Uart mySerial (&sercom3, 1, 0, SERCOM_RX_PAD_1, UART_TX_PAD_0); // Create the new UART instance assigning it to pin 1 and 0
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
mySerial.begin(9600);
pinPeripheral(1, PIO_SERCOM); //Assign RX function to pin 1
pinPeripheral(0, PIO_SERCOM); //Assign TX function to pin 0
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read on mySerial wired in loopback:
mySerial.write(sensorValue);
while (mySerial.available()) {
Serial.print(mySerial.read());
}
Serial.println();
delay(1); // delay in between reads for stability
}
// Attach the interrupt handler to the SERCOM
void SERCOM3_Handler()
{
mySerial.IrqHandler();
}
I am using an Analog Discovery 2 to try and read the serial values coming off the arduino and am stumped. It does not seem to be outputting anything?
I have the digital pin 0 connected to arduino pin 0, and I also tried to connect GND of the analog discovery 2 to the arduino GND with no luck.
Any ideas what I am doing wrong? Any other ideas for debugging this serial method?
