cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 - DMA Base Address Problem

manuel
Associate II
Posted on June 10, 2014 at 11:46

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 the

pcTxBuffer

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 #stm32
1 REPLY 1
Posted on June 10, 2014 at 13:32

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;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..