7 years, 2 months ago.

FRDM-K64F Where are the PeripheralPins.c int functions documented?

pinmap.h

typedef struct {
    PinName pin;
    int peripheral;
    int function;
} PinMap;

PeripheralPins.c

const PinMap PinMap_SPI_MISO[] = {
    {PTD3 , SPI_0, 2},
    {PTE1 , SPI_1, 7},
    {PTE3 , SPI_1, 2},
    {PTA17, SPI_0, 2},
    {PTB17, SPI_1, 2},
    {PTB23, SPI_2, 2},
    {PTC7 , SPI_0, 2},
    {PTD7 , SPI_1, 7},
    {NC   , NC   , 0}
};

PinMap seems to have these undocumented numbers set to them as a pin function e.g. 2 or 7 noted above. Does anyone know where these int functions are documented, or does anyone know what they mean and what the options are?

Thanks

2 Answers

7 years, 2 months ago.

In the reference manual of the MCU. Each pin can be generally connected to a number of peripherals/options, such as just GPIO, or AnalogIn, or SPI, or I2C, or PWM, etc. This goes via a multiplexer with a bunch of settings, and that number says in which setting that multiplexer needs to be to connect the pin to that peripheral internally.

Accepted Answer

Ok, so looking at the reference document * https://developer.mbed.org/media/uploads/GregC/k64f_rm_rev2.pdf for example PTD7, the functions denoted as ALT0-7 are the function numbers used in PeripheralPins.c?

Thanks

posted by Angus Hutton-McKenzie 01 Feb 2017

Yes exactly. There you also see that indeed SPI_1 is connected to ALT7 for that pin.

posted by Erik - 01 Feb 2017

Great thanks! One more question though... If a function field is empty, does this mean the IO is disabled when this option is chosen? Similarly if the field simply states the IO Pin Name does this place the function as a GPIO?

Thanks

posted by Angus Hutton-McKenzie 01 Feb 2017

When it simply states the name, it is indeed set as GPIO. I wouldn't actually know what happens if you choose an empty field.

posted by Erik - 01 Feb 2017

Thank you so much

posted by Angus Hutton-McKenzie 01 Feb 2017

Perhaps you might know something about my other question? https://developer.mbed.org/questions/76840/FDRM-K64F-Why-are-two-separate-SPI-perip/

posted by Angus Hutton-McKenzie 01 Feb 2017
7 years, 2 months ago.

Angus,

Adding to Erik's excellent answer, the peripheralpins.c for every specific target CPU/board is contained in the library source code, which you can find below. Click on mbed-src below and then Download repository to download the sources as a .zip file. /media/uploads/nixnax/red-on-white-arrow.jpg

Import librarymbed-src

mbed library sources

These sources are kept in sync with the latest mbed libraries. The best way to use it is to download this as a .zip file and unpack it somewehere on your machine. You can then browse and search the source at your leisure. The latest version is around 40 Mb, so it's a pretty fast download.

Enjoy, Nic

To add to Angus' his excellent answer: do that, only replace mbed-src by mbed-dev: https://developer.mbed.org/users/mbed_official/code/mbed-dev/, exactly the same, only mbed-src is depricated. They just did a name change.

posted by Erik - 01 Feb 2017

Thank you, im already using mbed-dev. This is where i captured the code sample posted in the question. I found it ok, just needed to understand it :P

posted by Angus Hutton-McKenzie 01 Feb 2017