rtc_15xx.h Chip_RTC_ClearStatus Bug?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

rtc_15xx.h Chip_RTC_ClearStatus Bug?

677件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by frh on Thu Jun 11 17:17:45 MST 2015
[color=#f00]Update 6/12/15: Looks like I posted to the wrong forum: rookie mistake. Found more on this will repost on LPC Open forum. Moderator, (if there is one), please remove this.[/color]

I'm following the lpc_open v2.08c example code for the RTC and it's not working. In my copy of rtc_15xx.h I find the following definitioins with identical implementations and I think it's incorrect in the case of the "Clear" function.

Shouldn't something like

pRTC->CTRL &= ~stsMask;  // corrected from original post


precede the return?

/**
 * @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 uint32_t Chip_RTC_ClearStatus(LPC_RTC_T *pRTC, uint32_t stsMask)
{
return pRTC->CTRL;
}

/**
 * @briefReturn RTC control/status register
 * @parampRTC: The base address of RTC block
 * @returnThe current RTC control/status register
 * @noteMask the return value with a RTC_CTRL_* definitions to determine
 *which bits are set. For example, mask the return value with
 *RTC_CTRL_ALARM1HZ to determine if the alarm interrupt is pending.
 */
STATIC INLINE uint32_t Chip_RTC_GetStatus(LPC_RTC_T *pRTC)
{
return pRTC->CTRL;
}
ラベル(1)
0 件の賞賛
返信
3 返答(返信)

646件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by frh on Sat Jun 13 13:54:14 MST 2015
Thanks for the feedback. You're right about the error. I gave a better answer when I reposted (but still to the wrong forum: the first time it was an honest mistake, the second time a really dumb one). It's here, FWIW.
0 件の賞賛
返信

646件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by frh on Sat Jun 13 13:54:12 MST 2015
Thanks for the feedback. You're right about the error. I gave a better answer when I reposted (but still to the wrong forum: the first time it was an honest mistake, the second time a really dumb one). It's here, FWIW.
0 件の賞賛
返信

646件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 1234567890 on Sat Jun 13 05:40:08 MST 2015
Original function seems to be wrong. It's just reading the register. Seems to be a copy&paste error from Chip_RTC_GetStatus(). Parameter uint32_t stsMask isn't used in the function...
But your solution is wrong as well: You write '0' to the bits.
UM says: "Writing a 1 clears this bit."
0 件の賞賛
返信