在ST网展上下了AN2548,上面说可以DMA可以直接外设到外设,也有个例子,把ADC的值直接用DMA发送到SPI上,DMA的初始化代码是这样的:
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&SPI1->DR;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
在这里,SPI->DR被看作是存储器地址,而非外设地址。这让我有点糊涂,所有外设在DMA控制器看来都可以当存储器吗?
如果所有外设地址都可被看成存储器地址,那么这一句“DMA_InitStructure.DMA_M2M = DMA_M2M_Disable”又表示什么呢? |