Connecting FEZ Touch and the Music Shield to the Domino Board ?!

If I connect both shields at the same time to the domino board,
I can´t play MP3 files, the MusicShield-Driver throws an invalid operation exception.

Initialize Touch-Shield:


FEZ_Components.FEZTouch.TouchConfiguration touch_config = new FEZ_Components.FEZTouch.TouchConfiguration(SPI.SPI_module.SPI1, FEZ_Pin.Digital.Di3, FEZ_Pin.Digital.An0);

Initialize Music-Shield:


MusicShield musicShield = new MusicShield(SPI.SPI_module.SPI1, FEZ_Pin.Digital.An4, FEZ_Pin.Digital.Di3, FEZ_Pin.Digital.Di4);

I am new to the SPI stuff. How does it work?

Kind regards,
Carlo

Is it FEZ Domino or FEZ Panda II?

What your exception is is probably important - tell us!

Here’s how SPI works. You use the common SPI connection lines. You also connect individual IOs to the “chip select” (CS) lines of the device. When SPI communicates to the device it sets the CS line, then performs actions on the SPI lines. So it shares the SPI lines by telling the device to pay attention and the others ignore activity on the SPI lines.

In the case of the Touch shield, there are two functions that have a CS function - the LCD uses one (2nd param in the ctor) and the Touch uses SPI and the CS pin is the 2nd param in the ctor. In your case, you’re attempting to use Di3.

In the case of the Music shield, there are two CS pins - one for the DATA portion and one for the COMMAND portion. The DATA pin is the 2nd parameter in the constructor - in your case AN4. COMMAND pin is the 3rd parameter in the ctor - Di3.

So now to the exception. Each device is trying to use Di3 for different purposes. They conflict, and the exception is telling you that the pin is already in use.

To un-do that, you need to rewire the devices from your Domino and connect at least one of them to an unused pin.

Speaking of unused pins, how is your LCD connected? I count at least 14 pins required for LCD function alone not counting touch. Quite an ask of a Domino with it’s smaller pincount.

Sorry, it was my fail (during try and error).

The initialization looks like this:


MusicShield musicShield = new MusicShield(SPI.SPI_module.SPI1, FEZ_Pin.Digital.An4, FEZ_Pin.Digital.An5, FEZ_Pin.Digital.Di4);

I´ve already re-wired some pins. So that the touch shield don´t use pins which the music shield use.
The touch display works. But if I hit the play button on the screen, the code above get executed and an InvalidOperationException is thrown at this line:

_spi = new SPI(_dataConfig);


_dataConfig = new SPI.Configuration((Cpu.Pin)dataCS, false, 0, 0, false, true, 2000, spi, (Cpu.Pin)DREQ, false);
_cmdConfig = new SPI.Configuration((Cpu.Pin)cmdCS, false, 0, 0, false, true, 2000, spi, (Cpu.Pin)DREQ, false);
_dreq = new InputPort((Cpu.Pin)DREQ, false, Port.ResistorMode.PullUp);

_spi = new SPI(_dataConfig);

Any help is appretiated.

Regards
Carlo

where are your definitions for dataCS, cmdCS, DREQ?

Hello Brett,

that is the Ctor of the MusicShield-Class.


public MusicShield(SPI.SPI_module spi, FEZ_Pin.Digital dataCS, FEZ_Pin.Digital cmdCS, FEZ_Pin.Digital DREQ)
{
....
}

I don´t understand the “Chip Select” thing. Both shields are having his own Chip Select Pin?
Normally the MusicShield must send data until end of file. When do I have the time to skip or abort via the touch panel?

Thanks in advance.

SPI is a bus. It has two wires, MOSI and MISO, that allow the MASTER to send data OUT (MOSI) to the bus, and that allow the master to get data IN (MISO) from the bus. That works perfectly when you have one device, the master talks on the MOSI line and the device has that as an input, and writes data back out on the other wire.

Now you want to talk to two devices. How do you do it? Well you have a DIFFERENT wire going to each device, called the Chip Select. When the device sees that line set (ie that chip is “selected”) then it reads the info from the master and is able to send.

So the answer is, yes, each device has to have it’s own CS line. In the case of the music shield, it needs two CS lines, one for “commands” and one for “data”.

the ctor info is useless. Somewhere before these lines:

_dataConfig = new SPI.Configuration((Cpu.Pin)dataCS, false, 0, 0, false, true, 2000, spi, (Cpu.Pin)DREQ, false);
_cmdConfig = new SPI.Configuration((Cpu.Pin)cmdCS, false, 0, 0, false, true, 2000, spi, (Cpu.Pin)DREQ, false);
_dreq = new InputPort((Cpu.Pin)DREQ, false, Port.ResistorMode.PullUp);

you set dataCS and cmdCS and DREQ as cpu.pins, what are their values? Are they wired to the correct pin?

I haven´t re-wired anything on the FEZ Music-Shield, so the values are:


MusicShield musicShield = new MusicShield(SPI.SPI_module.SPI1, FEZ_Pin.Digital.An4, FEZ_Pin.Digital.An5, FEZ_Pin.Digital.Di4);

That are the default pin assignments.

How can I set the CS to high or low for each device?
If I run my application, the touch display gets initialized and is running.

What I think is that I have to disable the CS for the Touch-Controller because it communicates also with SPI_module.SPI1 before I initialize the Music Shield. Right?

A simple code sample where two devices are controlled (SPI) would be appreciated.

Kind regards,
Carlo

Multiple devices GHI Electronics – Where Hardware Meets Software

Thank you.

That´s it. The FEZ Music Shield Driver and the FEZ Touch Driver has created his own SPI Object.
If I create a main SPI object and assign the different configurations using the SPI.Config Property then it works :wink:

Regards,
Carlo