Max no of UART on SAMD21G18(Sparkfun Mini Board)

Hi

I am currently working on a project where I need to communicate with 5 different sensors via UART alternatively & upload the data to PC.Currently the Setup is running using a Arduino Uno using Software Uart but I have chosen SAMD21G18 board from Sparkfun(Sparkfun Mini) for the final design.Although,I don't have any board currently with me.The problem is,i am unable to understand how many UART ports can be configured on the particular board??As far my understanding goes,i can configure the following pins as UARTs.Please take a look...

PA10 - SER0:2/2:2 - Tx //SER0:2 means Sercom0,Pad2(Therse are default hardware uart - Serial1)

PA11 - SER0:3/2:3 - Rx

PA09 - SER0:1/2:1 - Rx

PA08 - SER0:0/2:0 - Tx

PA14 - SER2:2/4:2 - Tx

PA15 - SER2:3/4:3 - Rx

PA20 - SER5:2/3:2 - Tx

PA21 - SER5:3/3:3 - Rx

PA06 - SER0:2 - Tx

PA07 - SER0:3 - Rx

Is my understanding correct??

As far my understanding goes,i can configure the following pins as UARTs.Please take a look...

PA10 - SER0:2/2:2 - Tx //SER0:2 means Sercom0,Pad2(Therse are default hardware uart - Serial1)
PA11 - SER0:3/2:3 - Rx
PA09 - SER0:1/2:1 - Rx
PA08 - SER0:0/2:0 - Tx
PA14 - SER2:2/4:2 - Tx
PA15 - SER2:3/4:3 - Rx
PA20 - SER5:2/3:2 - Tx
PA21 - SER5:3/3:3 - Rx
PA06 - SER0:2 - Tx
PA07 - SER0:3 - Rx

Is my understanding correct??

Hmm. I'm not sure how much you understand.

  • A single SerCom can only service a single serial port.
  • There are 4 "pads" associated with each SERCOM. on SAMD21, pad0 and pad2 can be transmit, and any pin can be receive.
  • SerComs are also used for SPI and I2C. I think that if you dont use SPI/I2C, you can re-use those SERCOMs for additional UARTs.
  • The normal D21 mini core configures SerialUSB (doesn't use a SERCOM), Serial1 (on D0/D1, using SerCom1, and Serial using SerCom5 "doesn't connect to pins" (would have connected to EDBG on Zero)

See SAMD21 pinout spreadsheet

With a "small" bit of effort, I think you should be able to get:
SerCom0 on D3/D4
SerCom1 (exists by default D0/D1) (Serial1)
SerCom2 on D2/D5
SerCom3 on SCL/SDA (normally I2C)
SerCom4 on A1/A2 (SERCOM4 is normally SPI on a Zero, but mini doesn't have it.)

SerCom5 is a bit tougher, since it's already configured in the core (I'm not sure whether you need to edit the core, or just reconfigure it after initialization.) It should be able to show up on D6/D7.
So, with a "small" amount of mucking around,

Thanks for your very nice explanation.It cleared all my doubts......
Although,prior to your answer,i did some digging myself & wrote a simple program(with Sercom2 & 4) & it compiled successfully!
One more thing i would like to ask(although this is irrelevant) that the ram usage is not showing up for this board at compilation end.
Will let u know if any problem occurs regarding the uart config!First,i will order a board for real time test.......

I think storage should get used by the Uart declarations.
Somewhere you should have something like:

Uart Serial2( &sercom0,  3, 4,           SERCOM_RX_PAD_1, UART_TX_PAD_0) ;
Uart Serial3( &sercom2,  5, 2,           SERCOM_RX_PAD_3, UART_TX_PAD_2 ) ;
Uart Serial4( &sercom3,  SCL, SDA,       SERCOM_RX_PAD_1, UART_TX_PAD_0) ;
Uart Serial5( &sercom4,  PIN_A2, PIN_A1, SERCOM_RX_PAD_1, UART_TX_PAD_0 ) ;

These do show up in the binary (...-nm *.elf):

536871200 00000188 B Serial2
536871388 00000188 B Serial3
536871576 00000188 B Serial4
536871764 00000188 B Serial5
536871952 00000188 B Serial
536872140 00000188 B Serial1
536872328 00000004 B sercom3
536872332 00000004 B sercom0
536872336 00000004 B sercom1
536872340 00000004 B sercom2
536872344 00000004 B sercom4

You'll have to fix/replace either uart.begin() or the variants file, since begin() essentially does

  // Set the pin to the special purpose (non-gpio) defined for that pin in variant.cpp
  pinPeripheral(uc_pinRX, g_APinDescription[uc_pinRX].ulPinType)

And the "extra" sercom pins are defined as things other than sercom/sercom_alt