Bug Report: LPC_Open v2.08c, rtc_15xx.h Chip_RTC_ClearStatus does nothing

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

Bug Report: LPC_Open v2.08c, rtc_15xx.h Chip_RTC_ClearStatus does nothing

790 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by frh on Fri Jun 12 21:29:20 MST 2015
I had trouble with the code for the rtc example project. In the course of digging through the code and the UM I noticed that the code for the functions [u]Chip_RTC_GetStatus[/u] and [u]Chip_RTC_ClearStatus[/u] are identical and only return the value of the CTRL register. The example code should still work in spite of this because it clears bit's that are already 0 and are set later to 1 before the RTC is enabled.

Shouldn't ClearStatus do something like the following

    pRTC->CTRL &= ~stsMask;
    pRTC->CTRL |= stsMask & RTC_CTRL_OFD;   // must write a 1 to clear this bit


prior to the return?
0 Kudos
Reply
3 Replies

777 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Tue Jun 16 04:51:17 MST 2015
You need to write a 1 for each status bit to clear, but protect bits 4 to 7 from changes. SWRESET (bit 0) is assumed to be 0. It is not specified what to do with the reserved bits, let's assume it is OK to write zeros.

So taking into account the comment it should probably be like this (untested, please test yourself):
/**
 * @briefClears latched RTC statuses
 * @parampRTC: The base address of RTC block
 * @paramstsMask: OR'ed status bits to clear
 * @returnNothing
 * @noteUse and OR'ed stsMask value of RTC_CTRL_OFD, RTC_CTRL_ALARM1HZ,
 *and RTC_CTRL_WAKE1KHZ to clear specific RTC states.
 */
STATIC INLINE void Chip_RTC_ClearStatus(LPC_RTC_T *pRTC, uint32_t stsMask)
{
   pRTC->CTRL = stsMask | (pRTC->CTRL & 0xf0);
}

0 Kudos
Reply

777 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by frh on Mon Jun 15 21:49:35 MST 2015
Thanks for the hint! Obviously I hadn't read the data sheet closely enough. I don't have a way to test this at the moment, but I think this should do it.

STATIC INLINE uint32_t Chip_RTC_ClearStatus(LPC_RTC_T *pRTC, uint32_t stsMask)
{
   pRTC->CTRL &= (stsMask ^ 0xf1);  
   return pRTC->CTRL;
}



0 Kudos
Reply

777 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 1234567890 on Sun Jun 14 03:09:47 MST 2015

Quote: frh

    pRTC->CTRL &= ~stsMask;




What will happen here to the flags that are set in the register but not in stsMask?
0 Kudos
Reply