Post Go back to editing

1.I want to set the processor 21489 SPI Slave. 2.I use ESP32 SPI master to keep on transmiting the 24 bytes (4-ADXL345 ACC data) to 21489. 3.How can i set the ADSP21489 SPIB to poll receiving the data by DMA interrupt. Could you provide the example code V

Category: Software

SPIB slave DMA setting

  • 1.I want to set the processor 21489 SPI slave.
    2.I use ESP32 SPI master to keep on transmiting the 24 bytes (4-ADXL345 ACC data) to 21489.
    3.How can i set the ADSP21489 SPIB to poll receiving the data by DMA interrupt.
    Could you provide the example code Visual DSP++ for me ?
    The previous example code no longer updates the value after receiving DMA data once

    void set_interrupt()
    {
    // clear registers, set RX/TX flush bits
    *pSPICTLB = (RXFLSH);
    *pSPIDMACB = FIFOFLSH;
    *pSPICTLB = 0;

    *pCPSPIB = 0;
    *pSPIFLGB = 0;
    *pSPISTATB = 0xff;

    *pSPIDMACB = 0;

    //*pSPIBAUDB = 0x2;
    //*pSPIFLGB = DS0EN;
    *pIISPIB = dest;
    *pIMSPIB = 1;
    *pCSPIB = N;

    // clear_RX_buffer();

    *pSPICTLB = WL8 | TIMOD2 | MSBF | CPHASE | CLKPL | SMLS | DMISO | GM;
    *pSPICTLB |= SPIEN;

    *pSPIDMACB = SPIRCV | INTEN;
    *pSPIDMACB |= SPIDEN;
    }

    void SPI_Rx_Isr(int sig)
    {
    //read data form dest
    ...
    //
    }
    --------
    while (1)
    {
    set_interrupt();
    interrupts(SIG_P18, SPI_Rx_Isr);
    while (!DMA_Rx_done)
    {
    asm("nop;");
    }
    ....
    //Calculate data
    ....
    }

  • Hi,

    Please refer the “Chained DMA Transfers”(Page No: 754/1304) programming model in the ADSP-21489 HRM manual.

    Please find the attached SPI slave receive example code for ADSP-212xx. Please use this as a reference.SPI DMA Chaining.zip


    Regards,
    Divya.P

  • Hello guys. I try it .But the Chained  DMA data from ESP32 master can only read once.

    I want to in ADSP while(1) keep on reading the variation data.

    The ESP32 master keep on transmitting the ACC real time data (24bytes) to 21489.

    I hope the received data is constantly changing, but there is no

    int dest_bufC[8];
    int dest_bufB[8];
    int dest_bufA[8];
    
    
    /* Transfer Control Blocks (TCB's)                        */
    int second_tcb[]= {0,         /* null CPSPI ends chain    */
                       sizeof(dest_bufC), /* count for final DMA   */
                       1,         /* IM for final DMA         */
                       (int) dest_bufC}; /* II for final DMA         */
    
    
    int first_tcb[]= {0, /* for CPSPI (next tcb) */
                      sizeof(dest_bufB), /* for CSPI (next count) */
                      1,           /* for IMSPI (next modify) */
                      (int) dest_bufB};    /* for IISPI (next index) */
    
    /* NOTE: Chain Pointer registers must point to the LAST   */
    /*        location in the TCB, "tcb + 3"  .  
    
    void Set_Chained_DMA()
    {
    	first_tcb[0] = (0x7FFFF & ((int)second_tcb + 3)); /* for CPSPI (next tcb) */
    	/* clear SPI settings                                     */
    	*pSPICTLB = 0;
    	*pSPIFLGB = 0;
    	*pSPIDMACB = 0;
    
    	/* setup first DMA in chain */
    	*pCSPIB = sizeof(dest_bufA); /* count = 8 words    */
    	*pIMSPIB = 1;				 /* step size = 1      */
    	*pIISPIB = (int)dest_bufA;	 /* point to dest_bufA */
    
    	/* set the SPI baud rate to CCLK/4*64 (781.25KHz @ 200MHz)*/
    	*pSPIBAUDB = 0x2;
    
    	/* configure DSP's SPI slave-select signals               */
    	*pSPIFLGB = DS0EN |						 /*enable SPI slave device select zero     */
    				SPIFLG3 | SPIFLG2 | SPIFLG1; /* Set SPIFLG0 low to     */
    	/*select SPI slave on FLAG0 pin    */
    
    	/* configure SPI port to power-on settings                */
    	*pSPICTLB = CPHASE | /* sample MISO on second edge of SPICLK  */
    				CLKPL |	 /* sampling edge of SPICLK is rising    */
    				WL8 |	 /* 32-bit words */
    				SPIEN |	 /* Enable SPI port */
    				SMLS |
    				TIMOD2; /* Start SPICLK when DMA is enabled      */
    
    	/*configure SPI for chained recieve DMA operation         */
    	*pSPIDMACB = SPIRCV |  /* DMA direction = receive               */
    				 SPICHEN | /* enable DMA chaining                   */
    						   //  INTEN |
    				 SPIDEN;   /* enabling DMA initiates the transfer   */
    
    	*pCPSPIB = (0x7FFFF & ((int)first_tcb + 3));
    }
    
    void main()
    {
    	...
    	Set_Chained_DMA();
    	while (1)
    	{
    	// read data form dest_bufA dest_bufB dest_bufC
    	//the data 
    	}
    }

    how can i set 21489 to recevie the read time data.Thank you.,

  • Hi,

    Please find the attached SPI example in chained DMA mode for ADSP-21489. Please use this as a reference and modify as per your requirement.

    As mentioned in the HRM under "Chain Assignment", The structure of a TCB is conceptually the same as that of a traditional linked-list. Each TCB has several data values and a pointer to the next TCB. Further, the chain pointer of a TCB may point to itself to continuously re run the same DMA. The I/O processor reads each word of the TCB and loads it into the corresponding register.

    Programs must assign the TCB in memory in the order shown in Figure 3-2 and Listing 3-1, placing the index parameter at the address pointed to by the chain pointer register of the previous DMA operation of the chain. The end of the chain (no further TCBs are loaded) is indicated by a TCB with a chain pointer register value of zero.ADSP_21489_SPI_DMA.zip

    Regards,
    Divya.P