Skip to main content
Associate III
October 15, 2025
Solved

How to fix the error of ""errMask" is undefined"?

  • October 15, 2025
  • 1 reply
  • 188 views

Hello Everybody,

Here are the software and boards in this case:

1. MC workbench 6.4.1
2. STM32 FW V1.28.2

I designed a project for my board, but the generated code has an error as illustrated in the picture, I didn't make any modification on the code and complie it directly after the generateion,

How can I fix the problem??Thank you!

 

errmask2.jpgerrmask1.jpg

Best answer by GMA

Hello @DF_MC,

Thank you for your report.
A ticket will be created on our side for the missing ErrMask definition when only bus voltage sensing is enabled on the M2 path. You can add the errMask definition as follows:

__weak void TSK_SafetyTask_PWMOFF(uint8_t bMotor)
{
 /* USER CODE BEGIN TSK_SafetyTask_PWMOFF 0 */

 /* USER CODE END TSK_SafetyTask_PWMOFF 0 */
 uint16_t CodeReturn = MC_NO_ERROR;
 uint8_t lbmotor = M1;
 const uint16_t errMask[NBR_OF_MOTORS] = {VBUS_TEMP_ERR_MASK, VBUS_TEMP_ERR_MASK2};
 /* Check for fault if FW protection is activated. It returns MC_OVER_TEMP or MC_NO_ERROR */

/* Due to warning array subscript 1 is above array bounds of PWMC_Handle_t *[1] [-Warray-bounds] */
 if (M2 == bMotor)
 {
 lbmotor = M2;
 }
 CodeReturn |= PWMC_IsFaultOccurred(pwmcHandle[lbmotor]); /* check for fault. It return MC_OVER_CURR or MC_NO_FAULTS
 (for STM32F30x can return MC_OVER_VOLT in case of HW Overvoltage) */

 if (M2 == bMotor)
 {
 uint16_t rawValueM2 = RCM_GetRegularConv(&VbusRegConv_M2);
 CodeReturn |= errMask[bMotor] & RVBS_CalcAvVbus(&BusVoltageSensor_M2, rawValueM2);
 }


 

  

1 reply

GMA
GMABest answer
Technical Moderator
October 15, 2025

Hello @DF_MC,

Thank you for your report.
A ticket will be created on our side for the missing ErrMask definition when only bus voltage sensing is enabled on the M2 path. You can add the errMask definition as follows:

__weak void TSK_SafetyTask_PWMOFF(uint8_t bMotor)
{
 /* USER CODE BEGIN TSK_SafetyTask_PWMOFF 0 */

 /* USER CODE END TSK_SafetyTask_PWMOFF 0 */
 uint16_t CodeReturn = MC_NO_ERROR;
 uint8_t lbmotor = M1;
 const uint16_t errMask[NBR_OF_MOTORS] = {VBUS_TEMP_ERR_MASK, VBUS_TEMP_ERR_MASK2};
 /* Check for fault if FW protection is activated. It returns MC_OVER_TEMP or MC_NO_ERROR */

/* Due to warning array subscript 1 is above array bounds of PWMC_Handle_t *[1] [-Warray-bounds] */
 if (M2 == bMotor)
 {
 lbmotor = M2;
 }
 CodeReturn |= PWMC_IsFaultOccurred(pwmcHandle[lbmotor]); /* check for fault. It return MC_OVER_CURR or MC_NO_FAULTS
 (for STM32F30x can return MC_OVER_VOLT in case of HW Overvoltage) */

 if (M2 == bMotor)
 {
 uint16_t rawValueM2 = RCM_GetRegularConv(&VbusRegConv_M2);
 CodeReturn |= errMask[bMotor] & RVBS_CalcAvVbus(&BusVoltageSensor_M2, rawValueM2);
 }


 

  

If you agree with the answer, please accept it by clicking on 'Accept as solution'.Best regards.GMA
DF_MCAuthor
Associate III
October 15, 2025

Hello @GMA , 

      Thanks for your reply. I really appreciate your help!