Comunicazione sercom mkr0

Ciao
Non riesco a comprendere come usare sercom su una board mkr0
Ho letto a suo tempo 2 link forniti ma non li ho compresi molto

+------------+------------------+--------+-----------------+--------+-----+-----+-----+-----+---------+---------+--------+--------+----------+----------+
 |            |      Serial1     |        |                 |        |     |     |     |     |         |         |        |        |          |          |
 | 13         | RX               |  PB23  |                 |   07   |     |     |     |     |         |  *5/03  |        |        |          | GCLK_IO1 |
 | 14         | TX               |  PB22  |                 |   06   |     |     |     |     |         |  *5/02  |        |        |          | GCLK_IO0 |
 +------------+------------------+--------+-----------------+--------+-----+-----+-----+-----+---------+---------+--------+--------+----------+----------+

Questo errore che ricevo

Arduino: 1.8.19 (Windows 10), Board: "Arduino MKRZERO"

core\variant.cpp.o: In function `SERCOM5_Handler':

C:\Users\stefano\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.13\variants\mkrzero/variant.cpp:182: multiple definition of `SERCOM5_Handler'

sketch\MST_mkr0_K_hc12_HTU21D_BT.ino.cpp.o:D:\Arduino sketches\folder datalogger_2\MST_mkr0_K_hc12_HTU21D_BT/MST_mkr0_K_hc12_HTU21D_BT.ino:334: first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Arduino MKRZERO.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Devo collegare un modulo hc12 ai pin RX e TX della mkr0
E come ultimo atto un modulo BT, ma questo dopo aver testato l'hc12

grazie
Stefano

Posta il tuo codice, difficile aiutarti senza vederlo

A me la Arduino MKRZero con IDE 1.8.9 compila senza errori usando semplicemente Serial1
(Poi non ho quella scheda e quindi non so se funziona)

void setup() {
  Serial1.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  Serial1.println("HIGH");
  delay(1000);                       
  digitalWrite(LED_BUILTIN, LOW);    
  Serial1.println("LOW");
  delay(1000);                       
}

Grazie
Con serial1 comunica
Comunque usare una mkr0 è una vera sofferenza
Adesso non carica più
IDE 1.8.19
Inoltre la scheda spesso blocca l ide che è una bellezza, unica soluzione scollegare

Hai qualcosa di collegato ai pin?

un RTC e un modulo HC12 oltre all uso dell SD integrata

A quali pin ?

1 Like

continuerò a studiare

//data 221210_2207
//master con mkr0
//per ricezione dati htu21d + termocoppia K
//from termometri distribuiti SLAVE(i) >> TO unità centrale memorizza MASTER
//comunicazione con HC12
//memorizza su SD
//utilizzo rtc DS1307
//aggiunto schermo oled
//aggiunto modulo BT

#include <SPI.h>  // SD SPI
#include <Wire.h> // OLED I2C, RTC DS1307 I2C

//---------------------------SERCOM BT
#include <Arduino.h>
#include "wiring_private.h"
//const byte HC12SetPin = 6; // "SET" Pin on HC12

//Uart Radio_BT (&sercom5, 13, 14, SERCOM_RX_PAD_0, UART_TX_PAD_2); // Create the new UART instance assigning it to pin 1 and 0

//--------------------------OLED I2C

#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
#define I2C_ADDRESS 0x3C  // 0X3C+SA0 - 0x3C or 0x3D
#define RST_PIN -1        // Define proper RST_PIN if required
SSD1306AsciiWire oled;    //nome display

//-------------------------------caratteri di comunicazione

char SLAVE_START;//carattere di start codice stazione SLAVE
char MASTER_START;//carattere di start stazione MASTER
char END;// carattere di end trasmissione
char rx;
int const maxdim = 40;
char stringa[maxdim];

int const maxdim_BT = 26; //massima dimensuione del vettore dati dallo SLAVE(i)
char send_this[maxdim_BT]; //stringa dati SLAVE(i)

//-------------------RTC DS1307 I2C

#include <TimeLib.h>
#include <DS1307RTC.h>

//---------------------Scheda SD SPI

#include <SD.h>
const int chipSelect = SDCARD_SS_PIN; //board mkr0
File datafile;
char logfile[12] = "datalog.txt"; //nome file di log

byte sensorNumTot; //numero toatle sensori
char id_sensor[8]; //vettore codice stazione aggiungere le stazioni se serve

char sending_SLAVE[4];

byte i, j, k, ol;//contatori

//sezione delay con millis()

unsigned long previousMillis; // will store last time LED was updated
long interval; //intervallo di campionamento

void setup()
{
  Serial.begin(9600); //Open serial port to computer
  Serial1.begin(9600); //Open serial port to computer modulo HC12

  Wire.begin(); //OLED I2C, RTC DS1307 I2C
  //Radio_HC12.begin(9600); //Open serial port to HC12

  //---------------------SERCOM HC12
  // pinPeripheral(13, PIO_SERCOM); //Assign RX function to pin 13
  //pinPeripheral(14, PIO_SERCOM); //Assign TX function to pin 14

  //---------------------SERCOM BT
  //  pinPeripheral(1, PIO_SERCOM); //Assign RX function to pin 1
  //  pinPeripheral(0, PIO_SERCOM); //Assign TX function to pin 0

  delay(500);

  //-----------------------OLED I2C
  Wire.setClock(400000L);
#if RST_PIN >= 0
  {
    oled.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN);
  }
#else // RST_PIN >= 0
  {
    oled.begin(&Adafruit128x64, I2C_ADDRESS);
  }
#endif // RST_PIN >= 0

  //-------------------OLED I2C set font

  oled.setFont(Adafruit5x7);
  //  oled.set2X();

  //------------------------HC12

//  pinMode(HC12SetPin, OUTPUT);
//  digitalWrite(HC12SetPin, HIGH);
  delay(1000);
//  Serial.println("HC12 ready:");

  //---------------------Scheda SD SPI

  Serial.println("Initializing SD card...");

  //--------------------------led allarm

  pinMode(7, OUTPUT);// led card not present
  pinMode(8, OUTPUT);// led no RTC
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);

  Serial.println("initialing SD card...");
  if (!SD.begin(chipSelect))// see if the card is present and can be initialized:
  {
    Serial.println("Card failed, or not present...");// don't do anything more
    digitalWrite(7, HIGH);
    while (1);
  }

  Serial.println("SD card initialized...");

  //  logfile = "datalog.txt"; //nome file di log dati

  SLAVE_START = '<';  //carattere inizio trasmissione stazione SLAVE
  MASTER_START = '#'; //carattere di start stazione MASTER
  END = '>';          // carattere di end trasmissione

  sensorNumTot = 3;

  id_sensor[0] = SLAVE_START; //carattere inizio trasmissione stazione SLAVE
  id_sensor[1] = 'a'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[2] = 'b'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[3] = 'c'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[4] = 'd'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[5] = 'e'; //aggiungere le stazioni se serve e aggiornare indice vettore
  id_sensor[6] = END; //caratte fine trasmissione
  id_sensor[7] = '\0'; //carattere null

  Serial.println(id_sensor);

  // id_sensor[8] = {SLAVE_START, '1', '2', '3', '4', '5', END, '\0'};

  // riceve e tratta i dati dalla radio
  char stringa[maxdim] = {0}; //il buffer di appoggio della trasmissione

  //interval = 140000 //= 7 min millis intervallo delle interrogazioni delle stazioni
  //interval = 120000 //= 6 min millis intervallo delle interrogazioni delle stazioni
  //interval = 100000 //= 5 min millis intervallo delle interrogazioni delle stazioni
  //interval = 80000  //= 4 min millis intervallo delle interrogazioni delle stazioni
  interval = 3000;    //= 15 sec millis intervallo delle interrogazioni delle stazioni


  previousMillis = 0;

  i = 0;
  j = 0;
  k = 0;
  rx = 0;

  delay(2000);
}

Non ho quella scheda, non saprei aiutarti.
Leggo dal sito arduino che la usb è collegata direttamente alla Serial, mentre Serial1 sono pin 13 e 14. Dal tuo schema non vedo problemi.
Speriamo qualcun'altro legga questo thread.

grazie
vedo di risolvere

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.