Bug: Chip_SCT_ClearEventFlag() clears ANY pending event

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bug: Chip_SCT_ClearEventFlag() clears ANY pending event

613 Views
rolfeigenheer
Contributor I

I found that Chip_SCT_ClearEventFlag in sct15xx.h clears all pending events. 

STATIC INLINE void Chip_SCT_ClearEventFlag(LPC_SCT_T *pSCT, CHIP_SCT_EVENT_T evt)
{
pSCT->EVFLAG |= evt;
}

UM10736: 

SCT event flag register
This register records events. Writing ones to this register clears the corresponding flags
and negates the SCT interrupt request if all enabled Flag bits are zero.

OR-ing will clear the evt as well as all events which read as '1'.

0 Kudos
4 Replies

447 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Rolf Eigenheer,

The “|=” operator includes the write operation, and it can clear the corresponding flags after execute the operator.

Hope this clear.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

447 Views
rolfeigenheer
Contributor I

Chip_SCT_ClearEventFlag(LPC_SCT_T *pSCT, CHIP_SCT_EVENT_T evt)  as implemented in the lib, reads the flags actually set and clears them all. The parameter evt has no use! 

An interrupt handler should read the pending events, handle them and clear the handled ones. Chip_SCT_ClearEventFlag clears also the events which came up later. In my opinion, this is a clear bug.

0 Kudos

447 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Rolf Eigenheer,

In the library, the event group includes a variety of options (Seeing below), so it doesn't clear all flags when choose some options.

And Chip_SCT_ClearEventFlag is the portion of interrupt handle routine, it only is used to clear the corresponding event flag.

/**
 * SCT Event values enum
 */
typedef enum CHIP_SCT_EVENT {
    SCT_EVT_0  = (1 << 0),    /*!< Event 0 */
    SCT_EVT_1  = (1 << 1),    /*!< Event 1 */
    SCT_EVT_2  = (1 << 2),    /*!< Event 2 */
    SCT_EVT_3  = (1 << 3),    /*!< Event 3 */
    SCT_EVT_4  = (1 << 4)    /*!< Event 4 */
} CHIP_SCT_EVENT_T;

Hope this clear.
Have a great day,
Ping

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

447 Views
rolfeigenheer
Contributor I

Hi Jeremy

Thanks for your response. But it is still not clear to me.

pSCT->EVFLAG |= evt;

this is the same as   pSCT->EVFLAG = pSCT->EVFLAG | evt

The value evt has no use. If the event flag is not set, then it cannot be cleared.

If it is set, then it is cleared anyway by pSCT->EVFLAG = pSCT->EVFLAG.  

If it should clear just the event 'evt', then the 'or' must be removed.

If it should clear all pending events, then no parameter evt is needed.

0 Kudos