Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAX32690 BLE_FreeRTOS Priority Issue #1231

Open
BrentK-ADI opened this issue Oct 16, 2024 · 0 comments
Open

MAX32690 BLE_FreeRTOS Priority Issue #1231

BrentK-ADI opened this issue Oct 16, 2024 · 0 comments

Comments

@BrentK-ADI
Copy link
Contributor

This issue was discovered in the MAX32690 BLE FreeRTOS example project. Other FreeRTOS projects across all MCUs should be evaluated.

In the FreeRTOSConfig.h file for this project, configMAX_PRIORITIES is redefined to be associated with the number of interrupt priorities. This is incorrect. configMAX_PRIORITIES is used to define the number of available task priorities in the FreeRTOS kernel, and unrelated to interrupts.

FreeRTOS Documentation
Project's FreeRTOSConfig.h

/* # of priority bits (configured in hardware) is provided by CMSIS */
#define configPRIO_BITS __NVIC_PRIO_BITS

#define configMAX_PRIORITIES ((0x1 << configPRIO_BITS) - 1)

/* Only the top three bits are implemented.  This is the lowest priority. */
#define configKERNEL_INTERRUPT_PRIORITY \
    ((unsigned char)configMAX_PRIORITIES << (8 - configPRIO_BITS))

From that redefinition, stack_dats.c uses configMAX_PRIORITIES to assign the IRQ priorities for the system. This works in the example project because of the redefinition of configMAX_PRIORITIES to be related to configPRIO_BITS. IRQ Priority Assignment.

/* Interrupts using FreeRTOS functions must have priorities between configMAX_PRIORITIES and
configMAX_SYSCALL_INTERRUPT_PRIORITY, lower priority number is higher priority */

/* Setup BLE hardware interrupt priorities */
NVIC_SetPriority(BTLE_TX_DONE_IRQn, (configMAX_PRIORITIES - 2));
NVIC_SetPriority(BTLE_RX_RCVD_IRQn, (configMAX_PRIORITIES - 2));
NVIC_SetPriority(BTLE_RX_ENG_DET_IRQn, (configMAX_PRIORITIES - 2));

However, if FreeRTOSConfig.h is changed or a "stock" FreeRTOSConfig.h is used without repurposing the configMAX_PRIORITIES definition, the IRQs will likely be assigned the wrong priority due to the shifting and masking done in the NVIC code.

All FreeRTOS projects should be revisited to ensure coherence with the intended use of these definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant