KL25Z SPI pin connections: Only a (small) subset available to mbed SPI

19 Jul 2013

This might also for other peripherals be the case, but I only looked at SPI: The source allows for only a few SPI pins: http://mbed.org/users/mbed_official/code/mbed-src/file/f9e72c209510/vendor/Freescale/KL25Z/hal/spi_api.c. While if you look at the user manual http://cache.freescale.com/files/32bit/doc/ref_manual/KL25P80M48SF0RM.pdf (10.3.1) there are many more options that the SPI pins can be connected to.

Is there a reason they aren't available for the mbed library? As example, I am fairly certain that contrary to what the wi-go pinout page says, SPI1_SCK is not PTE2, but PTB11. They are besides each other on the board, and according to the datasheet they are both available as SPI1 clock pins, so I guess it is an easy to make mistake, but mbed library doesn't accept PTB11.

Edit: Changing the spi_api.c to:

static const PinMap PinMap_SPI_SCLK[] = {
    {PTE2, SPI_1, 2},
    {PTC5, SPI_0, 2},
    {PTD1, SPI_0, 2},
    {PTB11, SPI_1, 2},
    {NC  , NC   , 0}
};

static const PinMap PinMap_SPI_MOSI[] = {
    {PTE1, SPI_1, 2},
    {PTC6, SPI_0, 2},
    {PTD2, SPI_0, 2},
    {PTD6, SPI_1, 2},
    {NC  , NC   , 0}
};

static const PinMap PinMap_SPI_MISO[] = {
    {PTE3, SPI_1, 2},
    {PTC7, SPI_0, 2},
    {PTD3, SPI_0, 2},
    {PTD7, SPI_1, 2},
    {NC   , NC   , 0}
};

Indeed allows communication via those spi pins (there are many more available, but these I need).

19 Jul 2013

Hello,

I did not add KL25 to mbed, thus I personally assume the same. There will be more pins available but mux options are not yet defined. I'll create a reminder, when I get back from vacation, I'll look at MUX options for KL25 and add them there.

Thank you for reporting. I'll keep you posted here.

Regards, 0xc0170

04 Aug 2013

Hello,

I am back, here are new SPI definitions.

static const PinMap PinMap_SPI_SCLK[] = {
    {PTE2, SPI_1, 2},
    {PTC5, SPI_0, 2},
    {PTD1, SPI_0, 2},
    {PTB11, SPI_1, 2},
    {PTD5, SPI_1, 2},
    {NC  , NC   , 0}
};

static const PinMap PinMap_SPI_MOSI[] = {
    {PTE1, SPI_1, 2},
    {PTC6, SPI_0, 2},
    {PTD2, SPI_0, 2},
    {PTE3, SPI_1, 2},
    {PTD7, SPI_1, 5},
    {PTC7, SPI_0, 5},
    {PTD3, SPI_0, 5},
    {PTD6, SPI_1, 2},
    {NC  , NC   , 0}
};

static const PinMap PinMap_SPI_MISO[] = {
    {PTE3, SPI_1, 2},
    {PTC7, SPI_0, 2},
    {PTD3, SPI_0, 2},
    {PTE1, SPI_1, 5},
    {PTA16, SPI_0, 5},
    {PTA17, SPI_0, 5},
    {PTC5, SPI_0, 5},
    {PTD2, SPI_0, 5},
    {PTD6, SPI_1, 5},
    {PTD7, SPI_1, 2},
    {NC   , NC   , 0}
};

static const PinMap PinMap_SPI_SSEL[] = {
    {PTE4, SPI_1, 2},
    {PTC4, SPI_0, 2},
    {PTD0, SPI_0, 2},
    {PTB10, SPI_1, 2},
    {PTD4, SPI_1, 2},
    {NC  , NC   , 0}
};

Thank you for pinpointing this lack of mux options. I am going to review all drivers.

Regards,

0xc0170

04 Aug 2013

Sounds good :). Quite an impressive list of possible pin maps.

05 Aug 2013

As I said, I have checked entire HAL, added more mux options where they were available.

They should be available when there will be the next update of the mbed src.

Regards,

0xc0170

06 Nov 2013

I ran into a "pinmap not found" error using:

PTC7 = mosi PTC6 = miso PTC5 = sclk PTC4 = ssel

I believe both PTC6 and PTC7 can be in either MOSI or MISO modes.

Are there other limitations? Here is my example:

FlashUSB flash(PTC7, PTC6, PTC5, PTC4);     //FlashUSB(PinName mosi, PinName miso, PinName sclk, PinName cs);

...kevin

06 Nov 2013

Never mind,

I was using mbed-src.lib instead of mbed.lib. All is right with the world now. Sorry for the false alarm.

...kevin