SPI and PortOut

30 May 2011

Hi,

I've configured a 16bit bus using the PortOut function but at the same time need access to one of the SPI interfaces unfortunately the 16 bit bus uses the same pins as the SPI interfaces. I've had ago at creating a SPI object when needed and then returning the pins back to the 16 bit bus using the PortOut function but it doesn't work. I guess the two can't use the same pins.

Is it possible to switch between the two in this way?

03 Jun 2011

I guess it's not possible then...

03 Jun 2011

Hi Robin,

The interface objects assume ownership of blocks/pins for their lifetime, and they are not really designed to support active switching between types as a primary function. This keeps the logic and the required internal state simpler.

However, you can still create and destroy interfaces dynamically just like you would any other C++ object, so if you did want to use new/delete to create one interface, then the other (then repeat), that should work; not ideal, but should give you what you want.

Simon

03 Jun 2011

Thanks Simon I will give that a go..

04 Jun 2011

Gave your suggestion ago but seems to conflict with recreation of the PortOut object. Does the SPI object's destructor leave any register values in tack that might conflict with settings used by the PortOut object?

12 Jun 2011

Sorry to push you on this one but is it the case?

12 Jun 2011

Hi Robin,

Close. It is actually PortOut that does not explicitly force the pin mux to gpio function, which normally isn't an issue as it is default; unless of course you are trying to use pins for multiple interfaces.

I'll look to get this added as a fix so it does work for this case. In the mean time, you could use BusOut (which won't have this problem) or poke the pinsel mux register to 0 yourself as a workaround.

Hope that is useful,

Simon

12 Jun 2011

Hi Simon,

Thanks for the help is the register defined in the LPC17xx.h file?