2022-12-17 02:14 AM
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!!
2022-12-17 02:51 AM
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.
2022-12-17 02:57 AM
Is this a "known good" hardware like Nucleo or Disco?
JW
2022-12-17 03:41 AM
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.
2022-12-17 03:56 PM
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();
2022-12-17 04:00 PM
080002ae <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>
2022-12-17 04:07 PM
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)
2022-12-17 04:29 PM
More specifically, GPIO is on AHB2 (Nothing else on AHB2), so it would seem that there is some kind of issue with AHB2 access.
2022-12-17 04:38 PM
Cube IDE debug
2022-12-17 05:03 PM
Even using:-
*((uint32_t *)addr) = 0xff;
if addr = 0x40020000 (AHB1) no problem
if addr = 0x48000000(AHB2) HARD FAULT