打印
[MCU]

关于用dmax的spi从模式进行传输的问题

[复制链接]
409|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
cr315|  楼主 | 2020-12-1 16:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
DMA, spi, ev, AN, NTC
芯片使用的是TI的tms320c6726b芯片,在使用dmax作为spi从模式进行传输过程中,发现进不去dmax的传输事件中断,现将程序表述如下:
void Dmax_spi_Init()
{
//dMAX event low priority
*(int*)(DMAX_CONTREG_BASE_ADD + DMAX_DELPR)= (0x1 << 13);
//EHP14 set as a low-priority event for SPI1
//dMAX event polarity
*(int*)(DMAX_CONTREG_BASE_ADD + DMAX_DEPR)= (0x1 << 13);
//event flag is set on rising edge
/********************* SPI1 RX EVENT ENTRY *****************************/
//event entry(event #13 entry) SPI1 RX DMA REQ
*(int *)( DMAX1_TRANSFER_ENTRY_BASE+13*4 )= (2<<0)|(1<<5)|(1<<6)|(0xA0<<8)|(3<<24) |(1<<28)|(0<<29);
//ETYPE 0x02 ,as a SPI RX transfer event.
//RELOAD=1;
//ESIZE = 01,8-bit element
//PTE = 0xA0, pointer to transfer entry #0
//TCC = 011;TCC3
//TCINT = 1 ;
//SPI:0
/********************* SPI0 RX TRANSFER ENTRY *****************************/
//transfer entry #0 (event #13 entry) SPI0 RX DMA REQ//
   *(int *)( DMAX1_TRANSFER_ENTRY_BASE+0*4 )= (unsigned int)(&tx_buf);
//tx src

*(int *)( DMAX1_TRANSFER_ENTRY_BASE+1*4 )=(unsigned int)(&rx_buf);
//rx dst
*(int *)( DMAX1_TRANSFER_ENTRY_BASE+2*4 )= 0xFF|(0x01 << 31);
//COUNT ACTIVE = 1
//PP = 0
*(int *)( DMAX1_TRANSFER_ENTRY_BASE+3*4 )= 0xFF;
//COUNT REFERENCE= 1
*(int *)( DMAX1_TRANSFER_ENTRY_BASE+4*4 )= (unsigned int)(&tx_buf);
//SRC0 = 1
*(int *)( DMAX1_TRANSFER_ENTRY_BASE+5*4 )= (unsigned int)(&rx_buf);
//DST0 = 1
*(int *)( DMAX1_TRANSFER_ENTRY_BASE+6*4 )=  (unsigned int)(&tx_buf);
//SRC1 = 1
*(int *)( DMAX1_TRANSFER_ENTRY_BASE+7*4 )= (unsigned int)(&rx_buf);
//DST1 = 1
*(int *)( DMAX_CONTREG_BASE_ADD+DMAX_DEDR )=(1<<13);
*(int *)( DMAX_CONTREG_BASE_ADD+DMAX_DEER )=(1<<13);

}


void SPIO_Init()
{


  Dmax_spi_Init();
   hSpi->regs->SPIGCR0  = 0x00;//reset spi0;
//SPI0_GCR0=0x00;//reset spi;
   delay(100);
   hSpi->regs->SPIGCR0  = 0x01;
//SPI0_GCR0=0x01;
/* 2. Configure SPI0 for slave */
   hSpi->regs->SPIGCR1  = 0x00;
//SPI0_GCR1=0x00;
/* 3. Configure SPI0 mode */
   hSpi->regs->SPIPC0 =  0x00000E00;
//SPI0_PC0 =pinmsk;
/* 4. Chose SPI0 SPIFMT0 */
   hSpi->regs->SPIDAT1  = 0x00000000;
//SPI0_DAT1=0x00000000;
/* 5. Configure SPI0 for SHIFTDIR=0,POLARITY=1,PHASE=0,
CHARLEN=8 8bit CHARLEN=10 16bit*/
   hSpi->regs->SPIFMT[0]  = 0x00020008;
//SPI0_FMT0=0x00020010;
/* 6. SPIDELAY for SPI0 not relevant in slave mode */
   hSpi->regs->SPIDELAY  = 0x00;
//SPI0_DELAY =0x00;
/* 7. Configure SPI0 for error notifications for OVR,BITERR and DESEL */
   hSpi->regs->SPIINT0 = 0x00000054;
//SPI0_INT0 =0x00000000;
   hSpi->regs->SPILVL  = 0x00;
//SPI0_LVL =0x00;
/* 8. Enable SPI0 communication */
   hSpi->regs->SPIGCR1  |= 0x01000000;
//SPI0_GCR1 |=0x01000000;
/* 9. Configure SPI0 for dmax servicing of spi events*/
   hSpi->regs->SPIINT0 |= 0x00010000;//执行完这里后就会将rx_buf的第一个字节置零
//SPI0_INT0 |=0x00010000;
/* 10. Let dMAX handle SPI data transfer and interrupt service routine handle
SPI error cases */
/* Configure dMAX channel to service SPI data transfers */
/* Perform any other processing */
   hSpi->regs->SPIDAT0=0x55;
}



在中断使能中,使能了中断8作为事件传输中断:
CSL_intcHookIsr( CSL_INTC_EVENTID_DMAXEVTOUT1, (Uint32)dmax_isr );   
    CSL_intcEventEnable( CSL_INTC_EVENTID_DMAXEVTOUT1, &eventstat );
其中#define CSL_INTC_EVENTID_DMAXEVTOUT1     (8)      /**<dMAXEVTOUT[1]*/

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1323

主题

3802

帖子

0

粉丝