Kinetis DMA & SPI

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

Kinetis DMA & SPI

3,439 Views
mntmrk
Contributor I

Hi,

 

I need to use link SPI with DMA.

I'm novice of PE, and I try to configure DMA and SPI but I don't find the right way to do it.

 

Please post me some usefull suggestion.....

 

Labels (1)
Tags (1)
0 Kudos
4 Replies

747 Views
ProcessorExpert
Senior Contributor III

Hi,

 

could you be more specific what for and how do you need to use the SPI ?

What Kinetis derivative are you using ?

 

best regards
Petr Hradsky
Processor Expert Support and Servicepacks Team


0 Kudos

747 Views
mntmrk
Contributor I

Hi,

 

I have to send a array of byte to led matrix using DMA.

The size of the buffer is from 10 up to 1024 byte

 

I'm working with K20N512VL processor. CW is 10.1

 

regards,

 

Mirko

0 Kudos

747 Views
ProcessorExpert
Senior Contributor III

Hi,

 

The SPIMaster_LDD component does not support DMA transfer so it's necessary to use peripheral initialization component Init_SPI and a component for setting up DMA transfer. It can be either Init_DMA or DMA_LDD accompanied with  DMA_Transfer.

 

Unfortunatelly, we don't have a specific example for SPI, however, there is an example of DMA configuration in the help of the DMA_Transfer component (use Help on component pop-up menu commend for the component) in the section Typical usage. One of the examples on that page is  '2- Memory-to-peripheral device nested transfers...' intended to be used with DAC paripheral.

 

best regards
Petr Hradsky
Processor Expert Support Team


747 Views
japex92
Contributor I
Hello

I am writing to know exactly how the DSPI bean works on the PE for the kinetis family (k53 and K60 to be precise). I have

followed a tutorial from freescale (Freescale Technical Information Center) and got the TX working properly; but I still don't get how TX and RX are set independently if the protocol is achieved by shifting the registers involved in the communication. I did activate the events related to SPI  SM1_ReceiveBlock and SM1_SendBlock, but dont know how to syncronize both if I have to receive data while it's transmiting.

I have also tried this on other code:

#define READ_SPI_FLASH_DATA()                 (unsigned char)SPI2_POPR

#define WAIT_SPI_RECEPTION_END()           while (!(SPI2_SR & SPI_SR_RFDF)) {}

#define CLEAR_RECEPTION_FLAG()              SPI2_SR |= SPI_SR_RFDF

#define WRITE_SPI_CMD0_LAST(byte)           SPI2_PUSHR = (byte | SPI_PUSHR_EOQ  | ulChipSelectLine | SPI_PUSHR_CTAS_CTAR0) // write final byte to output FIFO - this will negate the CS line when complete

WRITE_SPI_CMD0(0xff);                                    // write dummy

while( SPI_SR_EOQF != (SPI2_SR & SPI_SR_EOQF));

SPI2_SR = SPI2_SR | SPI_SR_EOQF | SPI_SR_TCF ;

SPI2_MCR |= 0xC01; // halt = 1

WAIT_SPI_RECEPTION_END();                                        // wait until at least one byte is in the receive FIFO

(void)READ_SPI_FLASH_DATA();                                     // discard

CLEAR_RECEPTION_FLAG();                                          // clear the receive flag

Please advise me what to do and how to read the RX buffer when transfering data bytes.



Cheers,

0 Kudos