-
MM32SPIN系列使用dma spi clk始终8位之间有一个时间间隔
我使用MM32SPIN27PF使用dma与硬件spi进行开发初始化代码如下:RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);//SPI2clkenableRCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1,ENABLE);//SPI_NSSGPIO_PinAFConfig(GPIOA,GPIO_PinSource4,GPIO_AF_0);//SPI_SCKGPIO_PinAFConfig(GPIOA,GPIO_PinSource5,GPIO_AF_0);//SPI_MISOGPIO_PinAFConfig(GPIOA,GPIO_PinSource6,GPIO_AF_0);//SPI_MOSIGPIO_PinAFConfig(GPIOA,GPIO_PinSource7,GPIO_AF_0);GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_7;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;GPIO_Init(GPIOA,&GPIO_InitStructure);GPIO_InitStructure.GPIO_Pin=GPIO_Pin_6;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;GPIO_Init(GPIOA,&GPIO_InitStructure);SPI_InitStructure.SPI_Mode=SPI_Mode_Master;SPI_InitStructure.SPI_DataSize=SPI_DataSize_8b;SPI_InitStructure.SPI_DataWidth=SPI_DataWidth_8b;SPI_InitStructure.SPI_CPOL=SPI_CPOL_Low;SPI_InitStructure.SPI_CPHA=SPI_CPHA_1Edge;SPI_InitStructure.SPI_NSS=SPI_NSS_Soft;//SPI_InitStructure.SPI_NSS=SPI_NSS_Hard;SPI_InitStructure.SPI_BaudRatePrescaler=spi_baud_div;SPI_InitStructure.SPI_FirstBit=SPI_FirstBit_LSB;SPI_Init(SPIx,&SPI_InitStructure);SPI_Cmd(SPIx,ENABLE);SPIM_TXEn(SPIx);SPIM_RXEn(SPIx);RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);//ʹÄÜDMA´«Êä//spi1rxchannel2DMA_DeInit(DMA1_Channel2);//½«DMAµÄͨµÀ2¼Ä´æÆ÷ÖØÉèΪȱʡֵDMA_InitStructure.DMA_PeripheralBaseAddr=(uint32_t)&(SPI1->RXREG);//DMAÍâÉèADC»ùµØÖ·DMA_InitStructure.DMA_MemoryBaseAddr=rx;//DMAÄÚ´æ»ùµØÖ·DMA_InitStructure.DMA_DIR=DMA_DIR_PeripheralSRC;//Êý¾Ý´
2021-07-12 0