2025-01-24 10:44 AM
Hi,
I have been making a lot of calls into null pointers and am quite surprised at the results. I am expecting hard failures when I make this mistake but instead it seems that things just keep going and it takes a long time to realize I failed to initialize a pointer.
e.g.
LL_UCPD_RxEnable(Ports[PortNum].husbpd);
I have made this call which resolves to
#define SET_BIT(REG, BIT) ((REG) |= (BIT))
__STATIC_INLINE void LL_UCPD_RxEnable(UCPD_TypeDef *UCPDx)
{
SET_BIT(UCPDx->CR, UCPD_CR_PHYRXEN);
}
I have made this with the value husbpd uninitialized. But nothing negative happens other than the operation doesn't complete. No crash or other error.
Is there anything I can do or enable that will produce a harder fault when I make this mistake?
2025-01-24 12:42 PM
There is memory mapped at ZERO, usually determined by the BOOTx pins
Perhaps enable asserts() so the library sanity checks the pointers/parameters passed into the HAL upper layers.
It will not help here, as it's not being checked.
You could fill uninitialized memory with 0xCDCDCDCD type pattern, or something similar, that's more likely to throw a fault when used.
Other Cortex-Mx parts you could perhaps play with watch points, or configure MPU to throw a MemManage_Handler