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.
10 years, 6 months ago.
How do I change polarity of the SPI data pin on the FRDM K64F
I'm using the SPI interface on PTD1-PTD3 and the I/O pin polarity is inverted, e.g. logic high between output words. How do I change the default polarity to be logic low?
Thanks!
Michael
3 Answers
10 years, 6 months ago.
I believe that is the default on the Freescale ones, high output when not used. The clock polarity/phase can be changed to comply with the required SPI waveforms, but I don't think the SPI data polarity is ever defined. I believe for example the NXP microcontrollers put the data pin in high-Z mode when they aren't used.
If it is important for you, you can manually switch it to a GPIO input node, or low GPIO output. (I have had for example a situation where the SPI device could be disabled by turning of the power supply, but due to the high data pin on Freescale devices it was still semi-powered via ESD diodes).
9 years, 11 months ago.
FRDM_K64F, SPI MODE 3 Supposed to send 170 ( 0xAA), but received 171. It seems that the MOSI jumps up too early and makes the LSB always be "1". How can I solve the problem?
FRDM_K64F, SPI MODE 3 Test
#include "mbed.h" SPI device(PTD6,NC,PTD5); int main() { int i = 0; device.format(8,3); while(1) { device.write(0x55); device.write(0xAA); wait(1); } }
I think it might be related to: https://github.com/mbedmicro/mbed/issues/840. It seems KSDK SPI peripheral (although iirc K20 uses the same one) has some timing issues with current code. Should get a seperate bug report on github.
posted by 11 Mar 201510 years, 6 months ago.
not sure, but in PIC (wow a long long time ago)
you set mode 0..3 or 1..4