Double use of pins

16 Sep 2010 . Edited: 16 Sep 2010

Trying to build a driver for the texas cc2500 chip I ran into a little problem

The cc2500 uses miso as a chip ready signal and you have to wait for it to become 0 before using clocking data.

I found out that after:

 

SPI spi(p5,p6,p7);
DigitalIn si(p6);

 

spi always reads 0 even if p6 is wired to vcc.

It can of course be solved by doubling miso to another -free- input but after:

 

DigitalIn si(p6);
SPI spi(p5,p6,p7);

all seems to work ok.

 

Probably the initialisation of DigitalIn resets some part of the SPI.

A better solution could be if SPI would have a spi.miso method just reading the misoPin as a DigitalIn.

greetings,

Art.

16 Sep 2010

Hi Art,

Sounds like an interesting project! Please tell us if you get something going!

As you show, the interfaces don't support having two modes of operation at the same time; you can't have two interfaces connected to the same pins.

What is actually happening under the hood in your example is that the pin MUX for p6 is being set to a SPI input, then to a DigitalIn, hence the SPI not functioning any more. However, in your second example, whilst again there is no reason why this should work, the input sensor of the LPC GPIO implementation actually works independently of the pin MUX, so you set it to DigitalIn (gpio), then to SPI, but the DigitalIn continues to work despite this! So it works, but more by luck/implementation details.

The recommended way would be to tie two pins together for the moment, unless you are happy knowing the fudge above just happens to work!

Simon

18 Oct 2010 . Edited: 18 Oct 2010

Hi Art,

Did you made any progress on this? I've got a couple of cc2500 modules lying around waiting to be used. :)

It's this module: http://www.quasaruk.co.uk/acatalog/DSQFM-TRX-2.pdf

I did some tests with them on a STM32 Primer32 and would like to use them also on the mbed board..

 

Sjoerd

19 Oct 2010

Hello Sjoerd,

Are those these?

http://ideetron.biedmeer.nl/Webwinkel-Product-602757/2.4-GHz-Transceiver-Module.html

There is slow progress.

I have a lot of other things to do!

Art.

19 Oct 2010

Art,

You could replace the DigitalIn object with a simple macro:-

// p6 is connected to P0.8
#define P6_HIGH (LPC_GPIO0->FIOPIN & (1UL << 8))

so then you could simply test it thus:-

if (P6_HIGH) {  
    // ... modeule not ready
}
else {  
    // ... yay, it's ready, let's go!
}
19 Oct 2010 . Edited: 19 Oct 2010

Hi Andy,

Thank you for your advice.

It's not really a problem at the moment.

I am using what Simon Ford called  (see above) the 'fudge' and that works well (for the moment).

user Simon Ford wrote:
The recommended way would be to tie two pins together for the moment, unless you are happy knowing the fudge above just happens to work!

 

I would like the spi class to have a method to just read the miso pin. Sounds easy to me :-)

I will review your method as soon as my driver gets serious enough to publish.

Art.

20 Oct 2010 . Edited: 20 Oct 2010

It should be easy. This compiles although I haven't tested it but isn't this the sort of thing you are looking for?

mySPI.h

#ifndef MYSPI_H
#define MYSPI_H

#include "mbed.h"

class mySPI : public SPI {
    public:
        mySPI(PinName mosi, PinName miso, PinName sclk, const char *name = NULL);
        bool miso(void);
    private:
        PinName _miso;
};

#endif

mySPI.cpp

#include "mbed.h"
#include "mySPI.h"

mySPI::mySPI(PinName mosi, PinName miso, PinName sclk, const char *name) : SPI(mosi, miso, sclk, name)
{
    _miso = miso;     
    if  (_miso == p6) LPC_GPIO0->FIOMASK &= ~(1UL << 8); 
    else LPC_GPIO0->FIOMASK &= ~(1UL << 17);
}

bool mySPI::miso(void) 
{
	if (_miso == p6) return (LPC_GPIO0->FIOPIN & (1UL << 8)) ? true : false;
	// else it can only be p12 (LPC1768 P0.17)
	else return (LPC_GPIO0->FIOPIN & (1UL << 17)) ? true : false;
}

Update: I added the mask clear to the constructor depending on which pin is miso.



20 Oct 2010

user Art Hoogendoorn wrote:

Hello Sjoerd,

Are those these?

http://ideetron.biedmeer.nl/Webwinkel-Product-602757/2.4-GHz-Transceiver-Module.html

There is slow progress.

I have a lot of other things to do!

Art.

Hi Art,

 

Yes, it looks like they're the same. I bought mine from farnell (farnell code: 1517428 Quasar code: QFM-TRX1-24G).

If you need any help with the library just let me know. I have some code working on a STM32 platform so it's pretty easy

to migrate that to mbed

 

 

Sjoerd

12 May 2012

I know this is an old post but I just got a couple of these cc2500 modules and was wondering if anyone had any code for them already?

Thanks Matthew