Compute Module 4 number of GPIO - Page 1
Forum section: electronics / projects

author: ricko_uk
author_rank: Super Contributor
timestamp: September 29, 2021, 11:44:58 pm
content: Hi,According to page 8 of the CM4 datasheet, it looks like the Compute Module 4 has only 30 GPIO pins (0 to 27, 44 and 45) but I need many more, at least 45.Two questions:1) Is that correct or can I use some other pins from CAM, HDMI, EEPROM or other peripherals as GPIO?2) If not, what is the best way to have more high-speed GPIOs (I2C port expander would not be fast enough)?Thank you

author: AaronLee
author_rank: Regular Contributor
timestamp: September 30, 2021, 12:44:40 am
content: I don't know anything about the Compute Module 4, but if you can't reuse some pins for alternate purposes, and if you can't find any off-the-shelf I/O expander with a direct interface (not I2C/SPI/etc), one solution would be to use a cheap MCU with plenty of I/O pins and make your own I/O expander. For example, if you need a lot of additional output lines on your CM4, design the interface as such:5 lines for an address (CM4 -> MCU)1 line for a strobe to update (CM4 -> MCU)1 line for data (CM4 -> MCU)Then 32 GPIO pins on the MCU will be outputs. You can customize the firmware in the MCU to set the defaults for each output pin as you desire, or use pullups/pulldowns to do it.Using that scheme, you'll use 7 lines on the CM4, for 32 pins, meaning a net increase of 25 pins. Adding one more address line would give you a net increase 56 pins.Alternately you could design it for input, though need to be more careful of the timing, and even I/O if you use one additional pin and additional logic.

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 30, 2021, 05:15:01 pm
content: Yes, I have seen a few projects using the CM4 that included an additional microcontroller to implement more GPIOs, but also to do some real-time low-level stuff that you can't do with the CM4 directly (unless maybe you were developing bare-metal on the CM4, which I doubt.)

author: langwadt
author_rank: Super Contributor
timestamp: September 30, 2021, 05:34:35 pm
content: Quote from: ricko_uk on September 29, 2021, 11:44:58 pmSMI and some registers?https://github.com/cariboulabs/cariboulite/blob/main/docs/smi/Secondary%20Memory%20Interface.pdf

author: ejeffrey
author_rank: Super Contributor
timestamp: September 30, 2021, 05:44:38 pm
content: I don't believe you can use any of the high speed peripheral pins as GPIO.There might be a couple of extra pins that you can assign, for instance the HDMI ports have associated I2C pins that you might be able to repurpose but I am not sure. I don't think there is any way you will get to 45.If you want something faster than shift registers and do word oriented IO you could use some transparent latches. For instance 4 16-bit transparent latches would consume 20 GPIO (16 data bits and 4 chip select pins) and result in 64 output pins. Updates to the currently selected bank would be zero overhead and switching banks would only take a few IO cycles.

author: ricko_uk
author_rank: Super Contributor
timestamp: October 01, 2021, 08:28:19 pm
content: Thank you allI2C and SPI expansions are not an option for the fast ones and space on the board is limited. I will go for a shift register.Thank you as always