Kinetis SPI Master Clock Polarity after Init

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Kinetis SPI Master Clock Polarity after Init

Jump to solution
2,063 Views
Vagni
Contributor IV

I am developing my application on Kinetis K60 with CodeWarrior 10.1 with ProcessorExpert 5.1 and MQX 3.7.

I need to drive an SPI bus in master mode, so I use the SPIMaster_LDD embedded component.

 

I initialize clock polarity as HIGH and clock phase as CHANGE ON LEADING EDGE.

 

But after the execution of the SPI_Init() function the CLK pin is at LOW level. Why? The clock line idle state should be high.

 

For this reason, my first SPI Master transaction to the slave device (which requires a high clock idle state) always fails.

However, after the first SPI transaction the CLK pin remains high, so all the subsequent SPI transactions are good.

 

As a workaround, I make a dummy SPI transaction of a single data byte after the SPI_Init() function call and then I can get all the real subsequent transactions to work properly.

 

Does the Kinetis SPI peripheral initialization make the CLK pin output the correct idle level set by the chosen clock polarity?

 

Labels (1)
Tags (1)
0 Kudos
1 Solution
823 Views
ProcessorExpert
Senior Contributor III

Hello,

 

I have discussed the problem with developers and the behaviour of SPIMaster_LDD i correct and correspond to the description of DSPI device in reference manual (RM).

 

The parameters of the communuicaiton are set during data transfer. For more details please see section: "49.3.7 DSPI PUSH TX FIFO Register In Master Mode (SPIx_PUSHR)" in RM. 

 

So, it seems your workaround was correct.

 

best regards
Vojtech Filip
Processor Expert Support Team

View solution in original post

0 Kudos
4 Replies
823 Views
sgraves
Contributor I

Even though this thread is long dead, I would like to correct the information in threads like these for those who are googling for solutions to various problems.  So this comment is for future googlers, not the original participants.

This thread demonstrates an often confused understanding of the clock polarity settings.  If the clock setting is active high then it will idle low.  So the clock was behaving correctly for the chosen setting.  If one wants an idle high and clocking on the rising edge (a very common SPI configuration) then the choices should be ACTIVE LOW and CLOCK ON SECOND EDGE.

0 Kudos
823 Views
ProcessorExpert
Senior Contributor III

Hello,

 

I am not aware of such problem in SPIMaster_LDD component. Could you please provide the ProcessorExpert.pe file from your project in order to analayze it?

 

best regards
Vojtech Filip
Processor Expert Support Team

0 Kudos
823 Views
Vagni
Contributor IV

Hello Filip,

 

See my attached ProcessorExpert.pe file.

 

Thank you.

0 Kudos
824 Views
ProcessorExpert
Senior Contributor III

Hello,

 

I have discussed the problem with developers and the behaviour of SPIMaster_LDD i correct and correspond to the description of DSPI device in reference manual (RM).

 

The parameters of the communuicaiton are set during data transfer. For more details please see section: "49.3.7 DSPI PUSH TX FIFO Register In Master Mode (SPIx_PUSHR)" in RM. 

 

So, it seems your workaround was correct.

 

best regards
Vojtech Filip
Processor Expert Support Team

0 Kudos