cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to simply turn PA0 HI on an STM32F030F4P6 using Cube IDE. No matter what I do, if I try to write to any GPIO registers (including using the auto generated Inits), I get a Hard Fault. Nothing solves it :(

BBrow.2
Associate III

I am trying to simply turn PA0 HI on an STM32F030F4P6 using Cube IDE.

No matter what I do, if I try to write to any GPIO registers (including using the auto generated Inits), I get a Hard Fault. Nothing solves it :( Tried debugging it, no matter what I do, I get a hard fault at any attempt to use any GPIO registers using any methods!!

18 REPLIES 18
S.Ma
Principal

Have you selected the right mcu in the project settings? If you can go in debug mode with st link, you can view and change all hw registers manually.

Is this a "known good" hardware like Nucleo or Disco?

JW

gbm
Lead III

Looking for sympathy or for help? In the 2nd case it is necessary to post some code including the port setup and the attempted operations.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
BBrow.2
Associate III

I have tried creating the project in MX Cube, but strangly, it does not open it in IDE cube like it does for other CPUs. Its code fails.

I have tried creating new project in IDE cube, it fails (Note:- IDE cube does not have STM32F030x4.h, it only has STM32F030x6.h).

I have tried manually doing everything.

One example:-

 HAL_Init();

// SystemClock_Config();

// MX_GPIO_Init();

 RCC->AHBENR |= (1<<17);

 RCC->AHBRSTR |= (1<<17);

 GPIOA->ODR = 0xFF;

Hard Fault at GPIOA->ODR = 0xFF;

same fault if I change it to GPIO->MODER etc

same fault if I include the SystemClock_Config(); and remove the RCC lines

different fault (Hard fault somewhere else) if I enable MX_GPIO_Init();

BBrow.2
Associate III

0693W00000WLFIKQA5.jpg080002ae <HardFault_Handler>:

/**

 * @brief This function handles Hard fault interrupt.

 */

void HardFault_Handler(void)

{

 80002ae: b580    push {r7, lr}

 80002b0: af00    add r7, sp, #0

 /* USER CODE BEGIN HardFault_IRQn 0 */

 /* USER CODE END HardFault_IRQn 0 */

 while (1)

 80002b2: e7fe    b.n 80002b2 <HardFault_Handler+0x4>

BBrow.2
Associate III

Stepping it from RESET shows it stops at the GPIO command (str - 800024a)

 GPIOA->ODR = 0xFF;

 8000244: 2390    movs r3, #144 ; 0x90

 8000246: 05db    lsls r3, r3, #23

 8000248: 22ff    movs r2, #255 ; 0xff

 800024a: 615a    str r2, [r3, #20]

//  GPIOA->

R3 appears to be correct (48000000 is GPIOA address, 20 more is ODR address)

BBrow.2
Associate III

More specifically, GPIO is on AHB2 (Nothing else on AHB2), so it would seem that there is some kind of issue with AHB2 access.

BBrow.2
Associate III

0693W00000WLFJmQAP.jpgCube IDE debug

BBrow.2
Associate III

Even using:-

*((uint32_t *)addr) = 0xff;

if addr = 0x40020000 (AHB1) no problem

if addr = 0x48000000(AHB2) HARD FAULT