2014-06-10 02:46 AM
Hi Guys,
I've a bit of an understanding problem of the DMA in a STM32F103 µC. I'm trying to set the base address to a pointer (not to an address of a static varialbe). My problem is, that if I set the pointer befor I use DMAInit(), all works. I I set the pointer afterwards, nothing works. For me is clear, that the problem is, that I change the address fo the pointer, but the base address of the DMA is not changed. Is there a way, that I can use pointers with DMA base address or do I have to use static global array, which address can never be changed? Some code may clarify what exactly my problem is.typedef
struct
{
uint8_t* pcTxBuffer;
///< Pointer to sending buffer
uint8_t* pcRxBuffer;
///< Pointer to receiving buffer
} xI2CLibTransfer_t;
xI2CLibTransfer_t g_xI2CLibTransfer;
DMA_DeInit(DMA1_Channel6);
// ...
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t) g_xI2CLibTransfer.pcTxBuffer;
// ...
DMA_Init(DMA1_Channel6, &DMA_InitStructure);
If I set the
pcTxBuffer
befor the DMA initialization, all works (but I never am able to change it) If I set thepcTxBuffer
afterwards, the MemoryBaseAddr points to a wring address. Is there any way I can make this happen with pointers? Thank you very much, Regargs Manuel #pointer #dma #stm322014-06-10 04:32 AM
If I set the
pcTxBuffer
befor the DMA initialization, all works (but I never am able to change it)If I set the
pcTxBuffer
afterwards, the MemoryBaseAddr points to a wring address. Is there any way I can make this happen with pointers? No, the peripheral does not perform this sort of indirection, you are not pointing the DMA unit at a memory descriptor, but rather loading values into specific registers. These aren't going to magically reload if you change the memory structure that was initially used./* Write to DMAy Channelx CMAR */
DMAy_Channelx->CMAR = DMA_InitStruct->DMA_MemoryBaseAddr;