This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RM57: Possible bug in HL_sys_startup.c reset cause vector

Other Parts Discussed in Thread: RM57L843, HALCOGEN

Hi all,

I think I've found a dormant bug in HL_sys_startup.c and would appreciate any comments you might have.

I am using HALCoGen 04.05.02 to generate code for the Hercules RM57L843.  In HL_sys_startup.c, in the reset-handler vector, there is a snippet of code that detects and reports ESM Group3 errors.

        /* Check if there were ESM group3 errors during power-up.
         * These could occur during eFuse auto-load or during reads from flash OTP
         * during power-up. Device operation is not reliable and not recommended
         * in this case. */
        if ((esmREG->SR1[2]) != 0U)
        {
           esmGroup3Notification(esmREG,esmREG->SR1[2]);               
        }

I think this usage is wrong.  See the prototypes for the esmGroup*Notification functions in HL_esm.h

/** @fn void esmGroup1Notification(esmBASE_t *esmREG, uint32 channel)
*   @brief Interrupt callback
*   @param[in] channel - Group 1 channel
*
* This is a callback that is provided by the application and is called upon
* an interrupt. The parameter passed to the callback is group 1 channel caused the interrupt.
*/
void esmGroup1Notification(esmBASE_t *esm, uint32 channel);

/** @fn void esmGroup2Notification(esmBASE_t *esmREG,uint32 channel)
*   @brief Interrupt callback
*   @param[in] channel - Group 2 channel
*
* This is a callback that is provided by the application and is called upon
* an interrupt. The parameter passed to the callback is group 2 channel caused the interrupt.
*/
void esmGroup2Notification(esmBASE_t *esm, uint32 channel);

/** @fn void esmGroup3Notification(esmBASE_t *esmREG, uint32 channel)
*   @brief Notification function for Group 3 Error
*   @param[in] channel - Group 3 channel
*
* This is a callback that is provided by the application
* The parameter passed to the callback is group 3 channel error.
*/
void esmGroup3Notification(esmBASE_t *esm, uint32 channel);

In other words, these functions take the channel number of a single ESM error.  But esmREG->SR1[2] is not a channel number, it is a bitfield of errors.  This is not consistent with the esmGroup3Notification's interface.

As generated by HALCoGen, the esmGroup*Notifications are all empty functions, so this doesn't make a difference.  But if a user implements the function without realizing how HL_sys_startup.c is using it, this will be a bug causing incorrect reporting of Group3 errors.  As Group3 errors are rare, it is also possible that a user may go a very long time before realizing this is a problem.  :)


What do you think?  Bug, or am I misunderstanding something?