demedeirosa
Posts: 15
Joined: Wed Jul 11, 2018 1:57 pm

CM3 using DPI, I2C and SPI

Wed Jul 11, 2018 2:06 pm

Hi all,

I am working on a project where I would like to use the CM3. According to info from the Adafruit website, DPI uses GPIO2-21. Presumably this pinout naming convention is the same from the other models to the CM. Looking at the CM datasheet, it appears that I2C0 is available on pins GPIO0 (SDA0) and GPIO1 (SCL0).

In addition, I would like to use SPI0 for using a MCP2515 CAN transceiver. Looking at the datasheet SPI0 is shown on both GPIO7-11 and GPIO35-39.

I assume that using either of these is relatively straight forward and just requires some configuration. Is that the case? Any issues with this approach?

Thanks!

aBUGSworstnightmare
Posts: 1084
Joined: Tue Jun 30, 2015 1:35 pm

Re: CM3 using DPI, I2C and SPI

Wed Jul 11, 2018 3:12 pm

DPI uses GPIO 0 (Zero) to 27 for 24-bit Color (GPIO0=clock Signal, GPIO1=DE 'Data Enable'). You want to use display in 18-bit color (mode5) so your DPI is on GPIO0-21.

You can configure your GPIO either by device tree or via overlays.

I2C0 is also available on GPIO28/29 = ALT0 or GPIO44/45 = ALT1 (refer to table 10 of the data sheet https://www.raspberrypi.org/documentati ... CM_2p0.pdf).

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5825
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: CM3 using DPI, I2C and SPI

Wed Jul 11, 2018 3:19 pm

DPI uses GPIOs 0-27 for 24bpp RGB. There are alternate modes as documented at https://www.raspberrypi.org/documentati ... /README.md which use a reduced colour depth.
Not all displays require the pixel clock (GPIO0) or Data Enable (GPIO1), but you'll need to check your display datasheet on that.

All pinmuxing options are documented in the peripheral datasheet, page 102.
I2C-0 is available on 0&1, 28&29, or 44&45 - either of those latter two options should be available to you.
I2C-1 is available on 2&3, or 44&45.
SPI0 is available on 7-11 or GPIO35-39.

Absolutely no issue with those mxuing options, you just need to set up device tree appropriately. There may already be some overlays available to do some of the work for you, but on the CM and CM3 there is an expectation you need to do a fair amount of your own DT work.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1883
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM3 using DPI, I2C and SPI

Wed Jul 11, 2018 3:19 pm

You can configure your GPIO either by device tree or via overlays.
I think you mean dt-blob.bin (which isn't Device Tree) or overlays (which are).

To enable DPI using an overlay put one of the following lines in config.txt:

Code: Select all

dtoverlay=dpi18
dtoverlay=dpi24
But note that, as aBUGSworstnightmare says, you'll need to use I2C on another GPIO pair.

demedeirosa
Posts: 15
Joined: Wed Jul 11, 2018 1:57 pm

Re: CM3 using DPI, I2C and SPI

Wed Jul 11, 2018 3:25 pm

Thanks everyone for all of the info.

From taking a quick look, the device tree configuration doesn't seem terribly difficult. Is that true? I haven't had much experience with device tree at all.

Thanks!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1883
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM3 using DPI, I2C and SPI

Wed Jul 11, 2018 3:41 pm

No, Device Tree isn't that hard. There are lots of example overlays in the kernel tree: https://github.com/raspberrypi/linux/tr ... s/overlays

There is also a utility called ovmerge (available here: https://github.com/raspberrypi/utils/bl ... ge/ovmerge) that applies overlays to a Device Tree in source form, allowing you to easily see what changes are being made. In the kernel source tree in arch/arm/boot/dts you could run:

Code: Select all

$ ovmerge -p bcm2710-rpi-3-b-plus.dts > base.dts              # Flatten the tree into a single text file
$ ovmerge base.dts overlays/dpi24-overlay.dts > new.dts       # Apply the overlay
$ diff base.dts new.dts 
342a343,347
> 			dpi24_pins: dpi24_pins {
> 				brcm,pins = <0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27>;
> 				brcm,function = <6>;
> 				brcm,pull = <0>;
> 			};
794a800,801
> 		pinctrl-names = "default";
> 		pinctrl-0 = <&dpi24_pins>;
837a845,846
> 	};
> 	__symbols__ {

demedeirosa
Posts: 15
Joined: Wed Jul 11, 2018 1:57 pm

Re: CM3 using DPI, I2C and SPI

Wed Jul 11, 2018 4:50 pm

PhilE,

Thank you for all of the help, I really appreciate it!!

Return to “Compute Module”