2013-12-04 10:46 PM
Hi ,
I am new to Stm32 . While browsing through the examples i noticed something that i dont understand for DMA . In the DMA-UART example,// In the initialzation code
DMA_InitStructure.DMA_PeripheralBaseAddr = USARTy_DR_Base;
// In the header file
#define USARTy_DR_Base 0x40004404
From the datasheet , UART2 is at 0x4000 4400 - 0x4000 47FF.
Why does the header file defines it at 0x 4000 4404 ?
Thanks
2013-12-05 03:24 AM
The uart perhiperal target/source for DMA transfer is the UART data register (USARTy_DR)
offset 0x00000004 in uart perhiperal register area. (See Usart register map table in device reference manual) Config also DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA transfer always read from/write to same register (or address if you prefer)2013-12-05 04:02 AM
Personally I think the following form is a bit more portable
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&USART1->DR;
// Register transfer goes to/from