Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 1 month ago.
How to use all SPI Slave Select pins for FRDM-K22F or FRDM-K64F
Is it possible to use the extra SPI slave select (SS) or chip select pins?
As an example pin 43 is SPI0_PCS4 and pin 44 is SPI0_PCS3 for the 64LQFP package on page 63 of: http://cache.freescale.com/files/microcontrollers/doc/data_sheet/K22P121M120SF7.pdf
When looking at: https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K22F/PeripheralPins.c
I don't see mappings for PTC0 and PTC1 as PinMap_SPI_SSEL pins.
How would I write mbed code to use these extra SPI SS pins for any of the SPI mbed libraries?
1 Answer
9 years, 1 month ago.
Add them to that file you linked. You just need the pin, the SPI it corresponds to, and the last number is the pin function number which is used to set that pin to slave select for the SPI. Then it should work.
Hello Erik,
I appreciate your reply.
I don't understand the last number in terms of why PTD5 is 7 for example: {PTD4 , SPI_1, 7},
Please would you explain what the number 7 relates to. I would like to able to add more SPI SS pins.
Would the following code be correct for PTC0 and PTC1 (not sure about the number 2)?
TARGET_K22F/PeripheralPins.c
const PinMap PinMap_SPI_SSEL[] = { {PTC0 , SPI_0, 2}, {PTC1 , SPI_0, 2}, {PTD0 , SPI_0, 2}, {PTE4 , SPI_1, 2}, {PTA14, SPI_0, 2}, {PTB10, SPI_1, 2}, {PTC4 , SPI_0, 2}, {PTD4 , SPI_1, 7}, {NC , NC , 0}
the above code from: https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K22F/PeripheralPins.c
I found the Signal Multiplexing section on page 60 for the K22F, and I look under column names ALT0, ALT1, ALT2, ALT3, ALT4, ALT5, ALT6, ALT7: http://cache.freescale.com/files/microcontrollers/doc/data_sheet/K22P121M120SF7.pdf
PTC0 and PTC1 are under column ALT2 as SPI0_PCS4 and SPI0_PCS3, which means the function number of 2 is correct.
posted by 08 Mar 2015If they are SPI0, yes.
Regarding the last number, in the reference manual there is a signal multiplexing chapter, with in there a pinout paragraph. I happened to have the K64F document over, and there PTC0 and PTC1 have the SSEL indeed on alternative function 2, so your code would be correct (assuming the K22F is equal to the K64F pinout for those).
posted by 09 Mar 2015