STM32F105作为从机发送数据,数据可以发送出去有时候对但是大部分时候都是错的,错的数据还是固定的,貌似是WS没有对其的问题,请教怎么解决?
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOA, ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_5;//I2SCK?I2SSD
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;//I2Sws
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI3, ENABLE);
/* CODEC_I2S peripheral configuration */
SPI_I2S_DeInit( SPI3 );
I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_8k;
I2S_InitStructure.I2S_Standard = I2S_Standard_PCMShort;
I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_32b;
I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;
I2S_InitStructure.I2S_Mode = I2S_Mode_SlaveTx;
I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Disable;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE);
DMA_DeInit(DMA2_Channel2);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&SPI3->DR);
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)APP_Tx_Buffer;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = APP_RX_DATA_SIZE;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA2_Channel2, &DMA_InitStructure);
SPI_I2S_DMACmd(SPI3, SPI_I2S_DMAReq_Tx, ENABLE);
DMA_Cmd(DMA2_Channel2, ENABLE);
DMA2_Channel2->CNDTR=0;
I2S_Init( SPI3, &I2S_InitStructure );
I2S_Cmd( SPI3, ENABLE );
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
不要在乎效率和容量。
一周热门 更多>