Arduino Forum

Products => Arduino Zero => Topic started by: timtailors on Jul 11, 2019, 09:31 pm

Title: Using pins 0,1 and deactivating PIN_SERIAL1_RX
Post by: timtailors on Jul 11, 2019, 09:31 pm
Hi,

I'm using the ATSAMD21G18A with a custom board and need to use pin 0,1 (porta11, porta10). I would like to remove in variant.h PIN_SERIAL1_RX, and PIN_SERIAL1_TX
When commenting out these two I'll get several errors. How can I safely remove them?

Code: [Select]
// Serial1
//#define PIN_SERIAL1_RX       (0ul)
//#define PIN_SERIAL1_TX       (1ul)
#define PAD_SERIAL1_TX       (UART_TX_PAD_2)
#define PAD_SERIAL1_RX       (SERCOM_RX_PAD_3)
Title: Re: Using pins 0,1 and deactivating PIN_SERIAL1_RX
Post by: westfw on Jul 16, 2019, 01:10 am
Quote
I would like to remove in variant.h PIN_SERIAL1_RX, and PIN_SERIAL1_TX
Why?  If you don't do the Serial1.begin(), you'll still be free to use those pins for whatever you want...
Yeah, it looks like there's about 2k of UART code that will get included in the sketch whether or not you use it, but I doubt that that will be relevant on a "large" chip like the SAMD.
It looks like editing variant.cpp instead of variant.h will get rid of the code...
Code: [Select]
SERCOM sercom3(SERCOM3);
SERCOM sercom4(SERCOM4);
#if 0
SERCOM sercom5(SERCOM5);

// Serial1
Uart Serial1(&sercom5, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX);

void SERCOM5_Handler()
{
  Serial1.IrqHandler();
}
#endif