9 years, 9 months ago.

Configuring FRDM KL25Z board for SPI communication with ADS1291

hello Sir,

I used the SPI code given in mbed handbook.I have used (PTD0 for PCS0)(PTD2 for MOSI),(PTD3 for MISO),(PTD1 for SCK) respectively. I just am in initialization stage and tried seeing the clock pulse. But still I am not able to view even that on oscilloscope Can you anyone tell me how I proceed further

Question relating to:

Another short time hack. This one is for test the behavior of the spi module. Probably an Oscilloscope is required to check the wave. FRDM-KL25Z, SPI

1 Answer

9 years, 9 months ago.

Hi, Suhasini-san,

Assuming that you are trying with my test_spi program.
Please try following.

(1) connect terminal program, i.e. TeraTerm with
= Serial port setup =
Port: (your frdm board)
Baud rate: 9600
Data: 8bit 
Parity: none
Stop: 1bit
= Terminal setup =
New-line / Receive : Auto
[v] Local echo

(2) type 'help'  in the terminal
command list will be printed.

(3) since it is very difficult to acquire single shot of SPI transaction,
let the program repeat it a lot, to do it use "loop" command, at the ">" prompt
type

> loop 100000

(3) then write some value, such as 0xA5, which is 165 in decimal value

> write 165

(4) at this point you should be able to see some clock and data move in your oscilloscope. (I hope)

(5) Note: in the doWrite function, I scanned the value as decimal value,

scanf("%d", &value) ;

may be you'd like to change it to

scanf("%X", &value) ;

moto

Accepted Answer

Thank you for the reply Sir, Sir when I referred the the FRDM KL25Z reference manual,it says that,as each pin has multiple functions, we will have to set up the alt modes to enable a particular function.Can you please tell how to set up the alt modes?

posted by suhasini s 25 Feb 2015

Dear Suhasini-san,

First of all, would you please call me "moto" or "Motoo" instead of Sir?

Returning to the question, yes, you are right, each pin must be
specified with which function that pin will be used.
But if you are developing/programming within mbed world
usually defining a module class instance will take care of it.

If you read the main.cpp in my test_spi program, with the line

SPI mySpi(PIN_MOSI, PIN_MISO, PIN_SCK) ; 

the pin function assignment is done automatically.

If you really would like to specify the MUX function,
you can directly specify the MUX bit using register, PORTx_PCRn
for example PORTD_PCR2 for PTD2.

But if you can survive using mbed class modules,
I would suggest to stick with it, since it's much easier and fun to use.

moto

posted by Motoo Tanaka 25 Feb 2015