cancel
Showing results for 
Search instead for 
Did you mean: 

HardFault error when accessing DMA configuration-bits using bitbanding

demonk
Associate
Posted on October 28, 2009 at 11:48

HardFault error when accessing DMA configuration-bits using bitbanding

2 REPLIES 2
demonk
Associate
Posted on May 17, 2011 at 13:27

Good morning,

I have a somewhat weird problem that is easy to reproduce, but I don't get the reason for it:

Code:

int main()

{

FLASH->ACR = 0x00000012;

stm32_ClockSetup(); //Nothing fancy, HSE on, PLL on...

BITACCESS(RCC->AHBENR)[0]=1; //DMA clock enable

DMA->CPAR3=0xAA5500FF; //Some random address values

DMA->CCMAR3=0x000AA000;

DMA->CNDTR3=0x05;

DMA->CCR3=0x00;

DMA->CCR3|=0x02; //Set Bit 1

DMA->CCR3|=0x01; //Set Bit 0

}

when I replace either of the last two lines using my BitBanding - Macro

(BITACCESS(DMA->CCR3)[1]=1; or BITACCESS(DMA->CCR3)[0]=1; like used before to set DMA clock in RCC), I run into a hard fault error.

Using the Keil simulator I can see in the DMA peripheral tab that the correct bits are set. But on the real hardware, hard fault every time.

The calculated bit addresses are correct, I checked that.

Did I miss something here? Can't I access these bits using bit banding? And why?

Regards

Benjamin

tomas23
Associate II
Posted on May 17, 2011 at 13:27

1. make sure you enable clock to (both) DMA units

2. make sure the address calculated with your macro is correct

3. btw. the DMA variable is initialized?

Hard fault is a generic collector for other exceptions, enable bus fault, usage and memory fault exceptions and read the source instruction address and reason in NVIC error registers.

[ This message was edited by: edison on 28-10-2009 16:19 ]