2021-06-29 09:10 PM
Hi, I'm currently using STM32F401RE Nucleo-64 Board.
My purpose of this project is to configure ISM330DLC Accelerometer, taking reference from STEVAL-BFA001V1B sample code on Vibration Analysis.
As a summary:
Nevertheless, the current problem I'm facing is this:
Sorry for the long post. I'm only just 2 months into STM32 and I would appreciate any kind advice and tips. Thank you.
Solved! Go to Solution.
2021-06-29 09:44 PM
> Once the accelerometer triggers the series of interrupt, my oscilloscope shows erratic behaviour, so i'm assumming its a priority problem. But all the other interrupts have a pre-empt priority of >= 1 after double checking.
Check again. If you're getting regular 1ms systick interrupts that are then interrupted when other interrupts happen, the only explanation is a priority issue or if they disable interrupts entirely.
While debugging, you should be able to hit pause to see what interrupt is being handled. If it's happening frequently, you should be able to spot it by doing this a few times.
2021-06-29 09:44 PM
> Once the accelerometer triggers the series of interrupt, my oscilloscope shows erratic behaviour, so i'm assumming its a priority problem. But all the other interrupts have a pre-empt priority of >= 1 after double checking.
Check again. If you're getting regular 1ms systick interrupts that are then interrupted when other interrupts happen, the only explanation is a priority issue or if they disable interrupts entirely.
While debugging, you should be able to hit pause to see what interrupt is being handled. If it's happening frequently, you should be able to spot it by doing this a few times.
2021-07-02 02:42 AM
Hi, Thanks for the response.
I think the reason has to do with HAL_INIT();
HAL_StatusTypeDef HAL_Init(void)
{
/* Configure Flash prefetch, Instruction cache, Data cache */
#if (INSTRUCTION_CACHE_ENABLE != 0U)
__HAL_FLASH_INSTRUCTION_CACHE_ENABLE();
#endif /* INSTRUCTION_CACHE_ENABLE */
#if (DATA_CACHE_ENABLE != 0U)
__HAL_FLASH_DATA_CACHE_ENABLE();
#endif /* DATA_CACHE_ENABLE */
#if (PREFETCH_ENABLE != 0U)
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
#endif /* PREFETCH_ENABLE */
/* Set Interrupt Group Priority */
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
/* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
HAL_InitTick(TICK_INT_PRIORITY);
/* Init the low level hardware */
HAL_MspInit();
/* Return function status */
return HAL_OK;
}
HAL_INIT has initially set to priority group 4 - which is 4 bits for pre-empt priority and 0 bits sub-priority.
BUT HAL_MSPInit() set the priority group again to priority group 0 - which is 0 bits pre-empt priority and 4 bits sub-priority.
/* USER CODE END 0 */
/**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
{
/* USER CODE BEGIN MspInit 0 */
/* USER CODE END MspInit 0 */
__HAL_RCC_SYSCFG_CLK_ENABLE();
__HAL_RCC_PWR_CLK_ENABLE();
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0);
/* System interrupt init*/
/* USER CODE BEGIN MspInit 1 */
/* USER CODE END MspInit 1 */
}
I guess I've learnt my lesson for not checking on HAL, but that implementation of initializing priority group twice just doesn't make sense.
2021-07-03 02:10 AM
I became looking to switch among simulator and a specific goal within the identical task while not having to create a new/second project detail article. But the "Import GUI" option does help too.
2021-07-17 07:48 AM
NVIC is already set to a maximum group priorities after reset. Therefore for a typical usage there is no reason in calling NVIC_SetPriorityGrouping() at all.
https://community.st.com/s/question/0D53W00000XHZKb/nested-interrupts-stm32l4