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, 7 months ago.
spi0 port not activated on mbed
The k22f has a SPI0 port on PC5, PC6, PC7 that does not seem to be usable in mbed. Every time I try to instantiate a spi object on these pins the rgb led blinks and the board is not active. Do any one have any idea on how I could get this port to work ?
I am currently bit - banging a spi port on this pins and I cannot achieve a transfer rate higher than 500kHz
Regards
Question relating to:
2 Answers
9 years, 7 months ago.
This is the list of SPI pins defined in the source files. At least make sure you have the latest version of the mbed library:
/************SPI***************/ const PinMap PinMap_SPI_SCLK[] = { {PTD1 , SPI_0, 2}, {PTE2 , SPI_1, 2}, {PTA15, SPI_0, 2}, {PTB11, SPI_1, 2}, {PTC5 , SPI_0, 2}, {PTD5 , SPI_1, 7}, {NC , NC , 0} }; const PinMap PinMap_SPI_MOSI[] = { {PTD2 , SPI_0, 2}, {PTE1 , SPI_1, 2}, {PTE3 , SPI_1, 7}, {PTA16, SPI_0, 2}, {PTB16, SPI_1, 2}, {PTC6 , SPI_0, 2}, {PTD6 , SPI_1, 7}, {NC , NC , 0} }; 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}, {PTC7 , SPI_0, 2}, {PTD7 , SPI_1, 7}, {NC , NC , 0} };
Thanks for this answer ! I should have the latest mbed library (using the online compiler) but i' don't get why when instantiating this SPI port, the freedom board gets all blinky (definitely not in my code).
posted by 10 Apr 2015I will have a look at it later. Only can you describe what you mean by all blinky? It should just blink the red LED, and due to state of the RGB LED it might result in other colors, but in the end it should just be a two-color blink.
Btw related to software SPI: DigitalOut on KSDK targets are horribly slow (blame Freescale for their library), you can use this lib if you really want fast IO: http://developer.mbed.org/users/Sissors/code/FastIO/. On most targets this gives a nice speed improvement, on KSDK targets a gigantic speed improvement.
posted by 10 Apr 2015IIn fact the problem is that i was misleaded by Freescale data sheet ... On freescale datasheet PTC7 is SPI0_SIN which i assumed was SlaveIN (like in MOSI) but is apparently SerialIn and thus refers to MISO ... Vendor should take great care to use good naming conventions to avoid this issue.
posted by 11 Apr 2015
Hi Jonathan, Can you please show me your code for setting the k22f as I am facing the same problems for days without any solution
posted by Richard Mensah 10 Mar 2016