I am using tm4c123g mcu, when power up it may drive a led up which can be seen easily to indicate running status. But sometimes(1/4 chances) it can not run.
Soon we find the mcu runs into hard fault and get the ti SPMA043.pdf to solve the problem with a near result from driver context:
//! \note It takes five clock cycles after the write to enable a peripheral
//! before the the peripheral is actually enabled. During this time, attempts
//! to access the peripheral result in a bus fault. Care should be taken
//! to ensure that the peripheral is not accessed during this brief time
//! period.
//!
//! \return None.
//
//*****************************************************************************
void
SysCtlPeripheralEnable(unsigned long ulPeripheral)
When we add a little delay in SysCtlPeripheralEnable, the Hard fault- bus fault did not appear when we tested 50 times;
Also, when we changed the CCS V5.2.1 optimization level -O2 --opt_for_speed=5 to none, the problem seems also disappeared.
I've checked the latest driver lib and find no changes about it.
So, advices please!