Grand Central M4 Express with 8 serial ports?

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
AlexJustAlex
 
Posts: 15
Joined: Wed Sep 08, 2021 3:41 pm

Grand Central M4 Express with 8 serial ports?

Post by AlexJustAlex »

I have a Grand Central M4 Express and 8 ttl to rs232 converters.

I'd like to use all 8 SERCOM as rs232 ports!

I assume I can, as the product page says "8 x hardware SERCOM (can be I2C, SPI or UART)"

The pinout page (https://learn.adafruit.com/adafruit-gra ... al/pinouts) references Serial1, SERCOM5, SERCOM1 and SERCOM4

I guess some of the others are labelled for i2c or spi?

I'm very familiar with rs232 coms but I'm new to the M4 and circuit python.

Can someone point me in the right direction for finding the relevant pins and setting them all as serial ports?

many thanks

Alex

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Grand Central M4 Express with 8 serial ports?

Post by dastels »

The definitive documentation is the SAMD5x datasheet: https://www.microchip.com/content/dam/m ... 01507G.pdf. Specifically section 34 "SERCOMUSART" on page 851.

Also, there's a guide on adding SERCOMs on SAMD boards: https://learn.adafruit.com/using-atsamd ... rial-ports.

Dave

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Grand Central M4 Express with 8 serial ports?

Post by westfw »

Yes, to use 8 serial ports, you would have to lose the I2C, SPI, and SD-card functions.
It looks like you can find them all on pins (rather than having to kludge something to the SD pins, for example.)
(it might even be possible to use SERCOM2 on pins 26/27, and then temporarily turn off the uart and access a device on the I2C pins using I2C, and then switch back (SERCOM2 on GCM4 is normally used for I2C.) But this would be complicated.)

See Spreadsheet of SAMD51 pins
and "library" for creating additional Serial ports

User avatar
AlexJustAlex
 
Posts: 15
Joined: Wed Sep 08, 2021 3:41 pm

Re: Grand Central M4 Express with 8 serial ports?

Post by AlexJustAlex »

Many thanks for those links!

User avatar
AlexJustAlex
 
Posts: 15
Joined: Wed Sep 08, 2021 3:41 pm

Re: Grand Central M4 Express with 8 serial ports?

Post by AlexJustAlex »

Both answers point to pages discussing arduino, .h files and .cpp files.

Please forgive my ignorance, but does this mean these solutions use the Arduino IDE rather than circuitpython?

thanks again

Alex

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Grand Central M4 Express with 8 serial ports?

Post by dastels »

Yes, they're C++ related. You might be able to use similar approaches in CircuitPython... creating UART objects with specific pairs of pins. I haven't tried it, myself.

Dave

User avatar
AlexJustAlex
 
Posts: 15
Joined: Wed Sep 08, 2021 3:41 pm

Re: Grand Central M4 Express with 8 serial ports?

Post by AlexJustAlex »

To expand a little, I want to capture data from 4 serial ports, log it to an sdcard and then write it back out on 4 more serial ports.

As I want to use the sd card, I now believe that reduces my available uarts.

Currently I belive that I have accessed 6

uart1in = busio.UART(board.TX, board.RX, baudrate=9600) # D1 and D0 SERCOM0
uart1out = busio.UART(board.TX1, board.RX1, baudrate=9600) # D18 and D19 SERCOM4

uart2in = busio.UART(board.TX2, board.RX2, baudrate=9600) # D16 and D17 SERCOM1
uart2out = busio.UART(board.TX3, board.RX3, baudrate=9600) # D14 and D15 SERCOM5

uart3in = busio.UART(board.D25, board.D24, baudrate=9600) # D25 and D24 SERCOM6
uart3out = busio.UART(board.D51, board.D52, baudrate=9600) # D51 and D52 SERCOM7

I can live with just capturing from 3 ports, but are there any other options I could explore for 2 more?

I do have a 2 channel rs232 hat that uses spi (https://www.waveshare.com/wiki/2-CH_RS232_HAT) I think that would require D51 and D52 so I'd lose one rs232 to gain 2, but 7 isn't actually any better than 6.

perhaps I could use 2 of these? I believe a second spi only requires a unique chip select line - this is not something I have done before and I am well aware that 'a little knowledge is a dangerous thing'


Thanks to the help given I am up and running with 6, but 8 would be nice

Alex

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Grand Central M4 Express with 8 serial ports?

Post by dastels »

You're right.

An SD card takes a SPI bux (so a SERCOM), and each SPI device requires one additional pin for a select line (all share SCK, MOSI, and MISO).

Dave

User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Grand Central M4 Express with 8 serial ports?

Post by westfw »

does this mean these solutions use the Arduino IDE rather than circuitpython?
yes; sorry. I didn't notice that you wanted to use CircuitPython.
(I guess the spreadsheet is equally (in)applicable to both. While it shows which pins can do which functions, it's pretty far from actual code of any sort.)

User avatar
AlexJustAlex
 
Posts: 15
Joined: Wed Sep 08, 2021 3:41 pm

Re: Grand Central M4 Express with 8 serial ports?

Post by AlexJustAlex »

Spreadsheet was extremely useful, many thanks

User avatar
adafruit_support_bill
 
Posts: 88095
Joined: Sat Feb 07, 2009 10:11 am

Re: Grand Central M4 Express with 8 serial ports?

Post by adafruit_support_bill »

Another option would be a serial port multiplexer such as this one: https://www.hackster.io/atlas-scientifi ... ect-181d48

User avatar
AlexJustAlex
 
Posts: 15
Joined: Wed Sep 08, 2021 3:41 pm

Re: Grand Central M4 Express with 8 serial ports?

Post by AlexJustAlex »

that certainly is another option!

thank you for the suggestion! =o)

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”