Skip to main content
HKapo.1
Associate II
October 27, 2022
Question

stm32h745 M4 Core doesn't work properly

  • October 27, 2022
  • 1 reply
  • 943 views

Hello All,

I have a STM32H745-DISCO board and trying to run a very simple program where M7 toggles Green LED and M4 toggles RED Led.

After programming, I can see that Green LED is toggling fine but RED LED is not.

Below is my simple main code:

M7:

int main(void)
{
 /* USER CODE BEGIN 1 */
 
 /* USER CODE END 1 */
/* USER CODE BEGIN Boot_Mode_Sequence_0 */
 int32_t timeout;
/* USER CODE END Boot_Mode_Sequence_0 */
 
 /* Enable I-Cache---------------------------------------------------------*/
 SCB_EnableICache();
 
 /* Enable D-Cache---------------------------------------------------------*/
 SCB_EnableDCache();
 
/* USER CODE BEGIN Boot_Mode_Sequence_1 */
 /* Wait until CPU2 boots and enters in stop mode or timeout*/
 timeout = 0xFFFF;
 while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) && (timeout-- > 0));
 if ( timeout < 0 )
 {
 Error_Handler();
 }
/* USER CODE END Boot_Mode_Sequence_1 */
 /* MCU Configuration--------------------------------------------------------*/
 
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();
 
 /* USER CODE BEGIN Init */
 
 /* USER CODE END Init */
 
 /* Configure the system clock */
 SystemClock_Config();
/* USER CODE BEGIN Boot_Mode_Sequence_2 */
/* When system initialization is finished, Cortex-M7 will release Cortex-M4 by means of
HSEM notification */
/*HW semaphore Clock enable*/
 
__HAL_RCC_HSEM_CLK_ENABLE();
/*Take HSEM */
HAL_HSEM_FastTake(HSEM_ID_0);
/*Release HSEM in order to notify the CPU2(CM4)*/
HAL_HSEM_Release(HSEM_ID_0,0);
/* wait until CPU2 wakes up from stop mode */
timeout = 0xFFFF;
while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) == RESET) && (timeout-- > 0));
if ( timeout < 0 )
{
Error_Handler();
}
 
/* USER CODE END Boot_Mode_Sequence_2 */
 
 /* USER CODE BEGIN SysInit */
 
 /* USER CODE END SysInit */
 
 /* Initialize all configured peripherals */
 MX_GPIO_Init();
 /* USER CODE BEGIN 2 */
 
 /* USER CODE END 2 */
 
 /* Infinite loop */
 /* USER CODE BEGIN WHILE */
 while (1)
 {
 /* USER CODE END WHILE */
		HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port,LED_GREEN_Pin);
		HAL_Delay(500);
		
 /* USER CODE BEGIN 3 */
 }
 /* USER CODE END 3 */
}

M4 Main:

int main(void)
{
 /* USER CODE BEGIN 1 */
 
 /* USER CODE END 1 */
 
/* USER CODE BEGIN Boot_Mode_Sequence_1 */
 /*HW semaphore Clock enable*/
 
 __HAL_RCC_HSEM_CLK_ENABLE();
 /* Activate HSEM notification for Cortex-M4*/
 HAL_HSEM_ActivateNotification(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0));
 /*
 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);
 /* Clear HSEM flag */
 __HAL_HSEM_CLEAR_FLAG(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0));
/* USER CODE END Boot_Mode_Sequence_1 */
 /* MCU Configuration--------------------------------------------------------*/
 
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();
 
 
 /* USER CODE BEGIN Init */
 
 /* USER CODE END Init */
 
 /* USER CODE BEGIN SysInit */
 
 /* USER CODE END SysInit */
 
 /* Initialize all configured peripherals */
 MX_GPIO_Init();
 /* USER CODE BEGIN 2 */
 
 /* USER CODE END 2 */
 
 /* Infinite loop */
 /* USER CODE BEGIN WHILE */
 while (1)
 {
 /* USER CODE END WHILE */
		HAL_GPIO_WritePin(LED_RED_GPIO_Port,LED_RED_Pin,GPIO_PIN_SET);
		//HAL_Delay(500);
 /* USER CODE BEGIN 3 */
 }
 /* USER CODE END 3 */
}
 

Can someone please help.

This topic has been closed for replies.

1 reply

HKapo.1
HKapo.1Author
Associate II
November 7, 2022

Hello community members,

I am stuck with this issue for quite some time.

Can you please help me with this?