cancel
Showing results for 
Search instead for 
Did you mean: 

Porting of code from STM32G431CB to STM32G431RBT6

STuser2
Senior

I have generated the code generated from MCSDK 6.4.0 for the micro STM32G431CB to STM32G431RBT6 micro.

My understanding is all the Hall drivers remain the same, the startup file and the .ld file will vary based on the micro controller. But i am running into the issue where ADC2 handler is getting called which it shall not as long as the PWM is OFF. 

STuser2_0-1754749495109.png

There is one signal handler called as shown above i am not sure what it is? I have been struggling to understand, please help.

1 ACCEPTED SOLUTION

Accepted Solutions

I found this issue yesterday and identified that there was an upgrade in msp.c / hal driver file as below

void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
{
  
  if(htim_pwm->Instance==TIM1)
  {
  /* USER CODE BEGIN TIM1_MspInit 0 */

  /* USER CODE END TIM1_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_TIM1_CLK_ENABLE();
  /* USER CODE BEGIN TIM1_MspInit 1 */

  /* USER CODE END TIM1_MspInit 1 */
  }
}

compared to previous version of 

void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)

i have verified that the problem was not occuring and was confident that was the root cause, but now again it is getting triggered not sure why. I will start checking the ADC1, ADC2 flags as you suggested. 

View solution in original post

10 REPLIES 10
MM..1
Chief III

Yes HAL is same , but no only ld require change. If you use Cube IDE check and change build defines etc.

Can you please tell me where the build defines will be in which files. I have generated the code using MCSDK 6.4.0 and then manually edited the files 

For pin mapping i have changed in main.h

stm32g4xx_hal_msp.c i have changed,

Application files i have changed. 

 

 

TDK
Super User

Set a breakpoint at ADC1_2_IRQHandler and check the flags of ADC1, ADC2 to see why it's being called.

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

I found this issue yesterday and identified that there was an upgrade in msp.c / hal driver file as below

void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
{
  
  if(htim_pwm->Instance==TIM1)
  {
  /* USER CODE BEGIN TIM1_MspInit 0 */

  /* USER CODE END TIM1_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_TIM1_CLK_ENABLE();
  /* USER CODE BEGIN TIM1_MspInit 1 */

  /* USER CODE END TIM1_MspInit 1 */
  }
}

compared to previous version of 

void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)

i have verified that the problem was not occuring and was confident that was the root cause, but now again it is getting triggered not sure why. I will start checking the ADC1, ADC2 flags as you suggested. 

STuser2_0-1754804011875.png

I can see the JEOS and EOS flag is set. 

STuser2_1-1754804089206.png

below message i am seeing when i click on the error.

fffffff9: Failed to execute MI command:
-data-disassemble -s 4294967289 -e 4294967322 -- 3
Error message from debugger back end:
Cannot access memory at address 0xfffffff8

 

Sorry , but you try drive Porshe without driver license... Signal handler in debug only mark , that hw invoke ISR.

Click on it get nothing + error.

I copied all the HAL drivers in the folder Drivers\STM32G4xx_HAL_Driver\Src from the reference folder, the interrupt does not happen now. Can you explain me please i am really not able to understand i tried to optimize by removing some of the src files in the HAL folder, then this issue happened, if the src files are required why i did not get compilation error. It is really confusing.

There are huge number of .c files in the folder

STuser2_0-1754821001840.png

more than this, i did not require them, what is the issue is it the root cause?

Hello @STuser2 

Could you specify which files you removed?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

@STuser2 wrote:

Can you please tell me where the build defines will be in which files.


In the Project Properties:

AndrewNeil_0-1754907206621.png

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.