cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO-H745: Testing interrupt on user button works in debug, not when programmed?

Rodo
Senior

Hi all,

I followed the tutorial "STM32CubeIDE basics - 04 EXTI HAL lab" video. I put the code in the CM4 core in my dual core NUCLEO-H745. I had an LED blinking in each core and that worked. I just added the interrupt stuff according to the tutorial video for the user button but it only works if I use debug and step thru the code. It doesn't work if I run the code. Only the interrupt stuff doesn't work. the LEDs blink just fine ... from both cores when run. What am I doing wrong?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Rodo
Senior

The solution to this is can be found in the example "GPIO_EXTI" for the Nucleo-H745 board. That example has "MPU_Config();" in the M7 main.c file. By adding the contents of that function (code posted below) in the same place in my M7 main.c (in main()) the problem was solved. Now the blue button works as expected in the M4 main.c file. BTW I tried adding the function and calling it but I got a few silly errors I didn't want to deal with:

Thanks Tech support!

static void MPU_Config(void)
{
  MPU_Region_InitTypeDef MPU_InitStruct;
 
  /* Disable the MPU */
  HAL_MPU_Disable();
 
  /* Configure the MPU as Strongly ordered for not defined regions */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.BaseAddress = 0x00;
  MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
  MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER0;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
  MPU_InitStruct.SubRegionDisable = 0x87;
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
 
  HAL_MPU_ConfigRegion(&MPU_InitStruct);
 
  /* Enable the MPU */
  HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}

View solution in original post

8 REPLIES 8
MM..1
Chief II

Better is show your code parts

My project has code for a I2C TFT display so I created a new project for the demo board and I just tried the interrupt stuff. I got the same results. Here is a zip of the new project.

Just so I'm clear. The LED (green and red) blink fine. The yellow LED that is supposed to turn on when I press the button (the ISR sets blueButtonPressed=1) only works when in debug session not when I click Run and program the board.

Thanks.

I just tried the CM7 core. Same code to turn the yellow LED using the user button and the CM7 core works as expected in run mode. There is something I'm missing in the CM4 but I dunno what.

MM..1
Chief II

Maybe change

uint8_t blueButtonPressed=0;

to

volatile uint8_t blueButtonPressed=0;

Interesting how the demo didn't use volatile. I tried it but it didn't work so in my frustration I started commenting code out and programming the board. I found that if I comment out the functions below, from the main function in the cm4, then the yellow LED works as expected. But the green LED that is blinked by the cm7 core no longer works. I'm pretty new to this stm32h745 so I'm not too sure what the functions do... homework for later :-). Thanks.

 /*
  Domain D2 goes to STOP mode (Cortex-M4 in deep-sleep) waiting for Cortex-M7 to
  perform system initialization (system clock config, external memory configuration.. )
  */
  HAL_PWREx_ClearPendingEvent();
  HAL_PWREx_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFE, PWR_D2_DOMAIN);

Rodo
Senior

The solution to this is can be found in the example "GPIO_EXTI" for the Nucleo-H745 board. That example has "MPU_Config();" in the M7 main.c file. By adding the contents of that function (code posted below) in the same place in my M7 main.c (in main()) the problem was solved. Now the blue button works as expected in the M4 main.c file. BTW I tried adding the function and calling it but I got a few silly errors I didn't want to deal with:

Thanks Tech support!

static void MPU_Config(void)
{
  MPU_Region_InitTypeDef MPU_InitStruct;
 
  /* Disable the MPU */
  HAL_MPU_Disable();
 
  /* Configure the MPU as Strongly ordered for not defined regions */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.BaseAddress = 0x00;
  MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
  MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER0;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
  MPU_InitStruct.SubRegionDisable = 0x87;
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
 
  HAL_MPU_ConfigRegion(&MPU_InitStruct);
 
  /* Enable the MPU */
  HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}

but...this is (region 4GB ) -> NOT_CACHEABLE + NOT_BUFFERABLE -->

switch off cache completely , right ?

and this is "solution" to get a LED blinking ???

come on...

If you feel a post has answered your question, please click "Accept as Solution".

They seem to be default values. You can enable the stuff in the visual configurator as the picture below shows but it adds extra functions:  MPU_Config(), SCB_EnableICache(),  SCB_EnableDCache().


_legacyfs_online_stmicro_images_0693W00000dDVp7QAG.png