Psoc5LP 10bits SPI slave with DMA

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
        I could receive 10bits data correctly with SPIS component by using SPIS_ReadRxData() API. Incoming SPI signal is as follows. 1. SS goes low. 2. Ten times SCLK and MOSI comes. 3. SS goes high. 4. Repeat 256 times.(step 1 ... 3) When I use DMA to transfer SPIS received data to SRAM, all stored data seems to be lower bytes. Can DMA access SPI 10bits FIFO? #define DMA_RX_1_BYTES_PER_BURST (2u) #define DMA_RX_1_REQUEST_PER_BURST (1u) #define DMA_RX_1_SRC_BASE (CYDEV_PERIPH_BASE) #define DMA_RX_1_DST_BASE (CYDEV_SRAM_BASE) unsigned char RxChannel_1; unsigned char RxTD_1[1u]; unsigned short data[256]; unsigned char DMA_RX1_Done; void init_dma(void) { /* Init DMA, 2 byte bursts, each burst requires a request */ RxChannel_1 = DMA_RX1_DmaInitialize(DMA_RX_1_BYTES_PER_BURST, DMA_RX_1_REQUEST_PER_BURST, HI16(DMA_RX_1_SRC_BASE), HI16(DMA_RX_1_DST_BASE)); RxTD_1[0] = CyDmaTdAllocate(); } void start_SPIS(void) { Dma_1_Rx1_Configuration(512, data); SPIS_1_ClearRxBuffer(); SPIS_1_Start(); } void stop_dma(void) { static unsigned char *STAT_RX1; do { CyDmaChStatus(RxChannel_1,NULL,STAT_RX1); } while((*STAT_RX1 & (STATUS_TD_ACTIVE | STATUS_CHAIN_ACTIVE)) != 0); CyDmaChDisable(RxChannel_1); SPIS_1_Stop(); } void Dma_1_Rx1_Configuration(unsigned short count, unsigned short *p) { CyDmaTdSetConfiguration(RxTD_1[0], count, CY_DMA_DISABLE_TD, TD_INC_DST_ADR | DMA_RX1__TD_TERMOUT_EN); CyDmaTdSetAddress(RxTD_1[0], LO16((uint32)SPIS_1_RXDATA_PTR), LO16((uint32)p)); CyDmaChSetInitialTd(RxChannel_1, RxTD_1[0]); CyDmaChEnable(RxChannel_1, 0u); } CY_ISR(ISR_DMA_RX1_Interrupt) { DMA_RX1_Done = 1; } void main(void) { for(;;){ if (DMA_RX1_Done){ stop_dma(); } if (/* event comes */){ start_SPIS(); } } }   
0 Likes
1 Reply
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

 Hello,

   

 

   

Can you please attach your project in which you have done the data read using DMA.

   

 

   

Thanks,

   

Hima

0 Likes