Or alternatively, just replace your "variant.cpp" and "variant.h" files (in the directory specified above) with these modified ones (attached). Void SERCOM2_Handler() // Interrupt handler for SERCOM2 Serial3.write(byteRead) // Echo the byte back out on the serial port If (Serial3.available()) // Check if incoming data is availableīyte byteRead = Serial3.read() // Read the most recent byte Uart Serial3(&sercom2, PIN_SERIA元_RX, PIN_SERIA元_TX, PAD_SERIA元_RX, PAD_SERIA元_TX) #define PAD_SERIA元_RX (SERCOM_RX_PAD_3) // SERCOM pad 3 #define PAD_SERIA元_TX (UART_TX_PAD_2) // SERCOM pad 2 #define PIN_SERIA元_TX (44ul) // Pin description number for PIO_SERCOM on D2 #define PIN_SERIA元_RX (45ul) // Pin description number for PIO_SERCOM on D5 Then to get Serial3 working on D5 (Rx) and D2 (Tx) on the Zero (or D5 (Rx) and D4 (Tx) on the M0 Pro), use the following code: // Serial3 pin and pad definitions (in Arduino files Variant.h & modified Variant.cpp) Computer\AppData\Roaming\Arduino15\packages\arduino\hardware\samd\1.6.1\variants\arduino_zero\variant.cpp: // 44.45 - SERCOM2 Just dd the two following lines to the end of the "g_APinDescription" array in the file. Implementing Serial3 however, requires a modification to the "variant.cpp" file. Void SERCOM1_Handler() // Interrupt handler for SERCOM1 Serial2.write(byteRead) // Echo the byte back out on the serial port If (Serial2.available()) // Check if incoming data is availableīyte byteRead = Serial2.read() // Read the most recent byte Uart Serial2(&sercom1, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX) #define PAD_SERIAL2_RX (SERCOM_RX_PAD_3) // SERCOM pad 3 #define PAD_SERIAL2_TX (UART_TX_PAD_2) // SERCOM pad 2 #define PIN_SERIAL2_TX (36ul) // Pin description number for PIO_SERCOM on D10 #define PIN_SERIAL2_RX (34ul) // Pin description number for PIO_SERCOM on D12 This code example simply echos back characters sent from the Arduino IDE console: // Serial2 pin and pad definitions (in Arduino files Variant.h & Variant.cpp) If it's not there, it's possible to get Serial2 working on D12 (Rx) and D10 (Tx) without modification to the "variant" files, using the following code in your Arduino sketch. Yes, "variant.cpp"/"variant.h" are the places to look.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |