11 years, 6 months ago.

SPI configuration problem

Can anyone suggest me the SPI0 setting for the FRDM KL25Z board. I tried simple module example of SPI given in the example but my MOSI port always transmit 0xFF Please input your suggestion.

Which program did you run?

posted by Martin Kojtal 18 Mar 2014

Please see my program as follows: For SS active high

The problem with the following program , is when i decode it using Osciiloscope ,it gives me garbage data instead of giving me 0x80 , 0x07 , 0x01 , 0x02

include "mbed.h" include "SPI.h" SPI temp_sensor(PTD2,PTD3,PTD1); mosi D11 , miso D12 , sclk D13 DigitalOut cs(PTD0); D10 Serial Pc(USBTX,USBRX);

int main() { while(1){

cs = 0;

Setup the spi for 8 bit data, high steady state clock, second edge capture, with a 1KHz clock rate temp_sensor.format(8,0); temp_sensor.frequency(1000);

Wait for some time before starting wait_ms(1000); temp_sensor.write(0x80);

temp_sensor.write(0x07);

temp_sensor.write(0x01);

temp_sensor.write(0x02); wait_ms(1000);

cs = 0;

} Please see my program as follows: For SS active high

The problem with the following program , is when i decode it using Osciiloscope ,it gives me garbage data instead of giving me 0x80 , 0x07 , 0x01 , 0x02

include "mbed.h" include "SPI.h" SPI temp_sensor(PTD2,PTD3,PTD1); mosi D11 , miso D12 , sclk D13 DigitalOut cs(PTD0); D10 Serial Pc(USBTX,USBRX);

int main() { while(1){

cs = 0;

Setup the spi for 8 bit data, high steady state clock, second edge capture, with a 1KHz clock rate temp_sensor.format(8,0); temp_sensor.frequency(1000);

Wait for some time before starting wait_ms(1000); temp_sensor.write(0x80);

temp_sensor.write(0x07);

temp_sensor.write(0x01);

temp_sensor.write(0x02); wait_ms(1000);

cs = 0;

}

}

posted by Nirmal Panchal 18 Mar 2014

1 Answer

11 years, 6 months ago.

Please see my program as follows: For SS active high

The problem with the following program , is when i decode it using Osciiloscope ,it gives me garbage data instead of giving me 0x80 , 0x07 , 0x01 , 0x02

  1. include "mbed.h"
  2. include "SPI.h"

SPI temp_sensor(PTD2,PTD3,PTD1); mosi D11 , miso D12 , sclk D13 DigitalOut cs(PTD0); D10 Serial Pc(USBTX,USBRX);

int main() { while(1){

cs = 0;

Setup the spi for 8 bit data, high steady state clock, second edge capture, with a 1KHz clock rate temp_sensor.format(8,0); temp_sensor.frequency(1000);

Wait for some time before starting wait_ms(1000); temp_sensor.write(0x80);

temp_sensor.write(0x07);

temp_sensor.write(0x01);

temp_sensor.write(0x02); wait_ms(1000);

cs = 0;

}

}

Please use <<code>> and <</code>> around it to make it better readable.

I don't see a reason why your code doesn't work. Some things are a bit weird, but not that it shouldn't work. One thing you can try is increasing the frequency, it might be below the minimum frequency the KL25Z can generate.

posted by Erik - 18 Mar 2014

Erik Olieman ,

Thanks for the suggestion , But I have already tried the same code at different frequencies like 1 Khz , 1Mhz. But It has same problem.

I can not see correct data transmission. Please post if you have any idea.

Any idea or help is welcome.

posted by Nirmal Panchal 19 Mar 2014