Jump to content

mattg

Newcomers
  • Posts

    1
  • Joined

  • Last visited

Posts posted by mattg

  1. Can someone please point me in the direction of a tutorial for reading UART from an arduino? Or perhaps point out where I might be going wrong.

    I am trying to output a string from TX on the arduino (MKRZERO) and receive it on the analog discovery 2 (AD2).

    I am using Digital I/O pin 0 on the AD2 that is connected to the arduino TX pin, and I assume I must also connect the AD2 ground to the arduino ground pin?

     

    arduino code here:

    #include <Arduino.h>   // required before wiring_private.h
    #include "wiring_private.h" // pinPeripheral() function
    
    Uart Serial2 (&sercom2, 3, 4, SERCOM_RX_PAD_1, UART_TX_PAD_0);
    void SERCOM2_Handler()
    {
      Serial2.IrqHandler();
    }
    
    void setup() {
      Serial.begin(115200);
    
      Serial2.begin(115200);
      
      // Assign pins 3 & 4 SERCOM functionality
      pinPeripheral(3, PIO_SERCOM_ALT);
      pinPeripheral(4, PIO_SERCOM_ALT);
    }
    
    uint8_t i=0;
    void loop() {
      Serial.print(i);
      Serial2.write(i++);
      if (Serial2.available()) {
        Serial.print(" -> 0x"); Serial.print(Serial2.read(), HEX);
      }
      Serial.println();
      
      delay(500);
    }

    image.thumb.png.828d77a4eb81fd9ac8d83d7f28098e48.png

×
×
  • Create New...