void SPI1_DMA_32B(unsigned char *p)
{
DMA_InitTypeDef DMA_InitStructure;
DMA_DeInit(DMA1_Channel3);
DMA_Cmd(DMA1_Channel3, DISABLE);
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Tx, ENABLE);
DMA_ClearFlag(DMA1_FLAG_TC3 | DMA1_FLAG_TE3 | DMA1_FLAG_HT3 | DMA1_FLAG_GL3);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&SPI1->DR; //外设地址,spi1
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)p;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 8;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;//使能外设地址不自增
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //使能存储目标地址自增
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; //不循环
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; //通道优先级高
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //非存储器至存储器模式
DMA_Init(DMA1_Channel3, &DMA_InitStructure);
DMA_Cmd(DMA1_Channel3, ENABLE);
}
void vs1053test()
{
// unsigned char i;
unsigned char a[8]={0x53,0xef,0x6e,0x44,0,0,0,0};
unsigned char b[8]={0x45,0x78,0x69,0x74,0,0,0,0};
xdcs=0;
while(dq==0) ;
SPI1_DMA_32B(a);
while(dq==0) ;
delay_ms(1860);
SPI1->DR;
SPI1_DMA_32B(b);
xdcs=1;
while(1);
}
用JLINK调试时,两段数组都能发送出去,运行时却只发送了第一组。。求大神解答 |