Part Number: CC3551E
Hi,
During my debugging sessions on the CC35x1 LaunchPad (Rev E3) with SimpleLink Wi-Fi SDK (9_19_00_02_ea), I've stumbled over the exception decoding in "\simplelink_wifi_sdk_9_19_00_02_ea\kernel\freertos\exception\ExceptionArmV8M.c" - e.g. Exception_decodeBusFault:
/*
* ======== Exception_decodeBusFault ========
*/
static void Exception_decodeBusFault(Exception_ExceptionContext *exceptionContext)
{
uint8_t bfsr = (SCB->CFSR & SCB_CFSR_BUSFAULTSR_Msk) >> SCB_CFSR_BUSFAULTSR_Pos;
/* Decode BFSR to determinte what kind of MemFault it is. */
if (bfsr & SCB_CFSR_STKERR_Msk)
{
Log_printf(LogModule_Exception,
Log_ERROR,
"Exception_decodeBusFault: BusFault caused by stack push. (STKERR)");
}
The bfsr variable/value is extracted nicely, masked and shifted down. But all the if-else clauses below use masks, e.g. SCB_CFSR_STKERR_Msk, that include the same amount of masks and shifts which should be applied directly on the SCB->CFSR register instead:
#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ #define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ #define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ #define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */
[simplelink_wifi_sdk_9_19_00_02_ea\source\ti\devices\cc35xx\cmsis\core\core_cm33.h]
That is, "bfsr" should be removed entirely and the if-else clauses should use SCB->CFSR directly:
/*
* ======== Exception_decodeBusFault ========
*/
static void Exception_decodeBusFault(Exception_ExceptionContext *exceptionContext)
{
/* Decode BFSR to determinte what kind of MemFault it is. */
if (SCB->CFSR & SCB_CFSR_STKERR_Msk)
{
Log_printf(LogModule_Exception,
Log_ERROR,
"Exception_decodeBusFault: BusFault caused by stack push. (STKERR)");
}
The same goes for Exception_decodeUsageFault().
(and just for symmetry, also for Exception_decodeMemFault(), but there the shifts are zero, so no harm done.)
Right?