如题所示:
使用了M482KGC开发板,用了PF6 7 8的spi0进行主机发送数据,
调用了spi的发送函数,可以发送出数据,spi0的io至少配置成功。
后加上dma功能,发现怎么配置都是发不出数据,也对了bsp里的历程,配置的也一致,但仍发送不出数据
大佬们帮忙看下是哪里配置不对,万分感谢
初始化函数:
#define M_SPI_PDMA_CH 15
void master_spi_init(void ){
SYS_UnlockReg();
CLK_EnableModuleClock(PDMA_MODULE);
CLK_SetModuleClock(SPI0_MODULE, CLK_CLKSEL2_SPI0SEL_PCLK1, MODULE_NoMsk); //CLK_CLKSEL2_SPI0SEL_PCLK1
/* Enable SPI0 peripheral clock */
CLK_EnableModuleClock(SPI0_MODULE);
/* Setup SPI0 multi-function pins */
// SYS->GPF_MFPH &= ~(SYS_GPF_MFPH_PF9MFP_Msk | SYS_GPF_MFPH_PF8MFP_Msk);
// SYS->GPF_MFPH |= (SYS_GPF_MFPH_PF9MFP_SPI0_SS | SYS_GPF_MFPH_PF8MFP_SPI0_CLK);
SYS->GPF_MFPH &= ~(SYS_GPF_MFPH_PF8MFP_Msk);
SYS->GPF_MFPH |= ( SYS_GPF_MFPH_PF8MFP_SPI0_CLK);
SYS->GPF_MFPL &= ~(SYS_GPF_MFPL_PF7MFP_Msk | SYS_GPF_MFPL_PF6MFP_Msk);
SYS->GPF_MFPL |= (SYS_GPF_MFPL_PF7MFP_SPI0_MISO | SYS_GPF_MFPL_PF6MFP_SPI0_MOSI);
/* Enable SPI0 clock pin (PF8) schmitt trigger */
PF->SMTEN |= GPIO_SMTEN_SMTEN8_Msk;
SPI_Open(SPI0, SPI_MASTER, SPI_MODE_0, 32, (uint32_t)5000000);
// SPI_EnableAutoSS(SPI0, SPI_SS, SPI_SS_ACTIVE_LOW);
SPI_SET_MSB_FIRST(SPI0);
PDMA_Open(PDMA, (1 << M_SPI_PDMA_CH)); //spi0
PDMA_SetTransferCnt(PDMA,M_SPI_PDMA_CH, PDMA_WIDTH_32, 100);
PDMA_SetTransferAddr(PDMA,M_SPI_PDMA_CH, (uint32_t)&send[0], PDMA_SAR_INC, (uint32_t)&SPI0->TX, PDMA_DAR_FIX);
PDMA_SetTransferMode(PDMA,M_SPI_PDMA_CH, PDMA_SPI0_TX, FALSE, 0);
PDMA_SetBurstType(PDMA,M_SPI_PDMA_CH, PDMA_REQ_SINGLE, 0);
PDMA->DSCT[M_SPI_PDMA_CH].CTL |= PDMA_DSCT_CTL_TBINTDIS_Msk;
SYS_LockReg();
}
外层开了一个定时器循环触发dma
void start_spi_send(void){
PDMA_CLR_TD_FLAG(PDMA,1<<M_SPI_PDMA_CH);
PDMA_SetTransferCnt(PDMA,M_SPI_PDMA_CH,PDMA_WIDTH_32, 100);
PDMA_SetBurstType(PDMA,M_SPI_PDMA_CH, PDMA_REQ_SINGLE, 0);
SPI_TRIGGER_TX_PDMA(SPI0);
}
|