diff --git a/bsp/lpc43xx/M0/applications/board.c b/bsp/lpc43xx/M0/applications/board.c index 116c433040c8842a202b8e68fe146c632880bbff..c3377aac2a3711c07388b00f38402cc9b1b3588a 100644 --- a/bsp/lpc43xx/M0/applications/board.c +++ b/bsp/lpc43xx/M0/applications/board.c @@ -26,17 +26,34 @@ void RIT_OR_WWDT_IRQHandler(void) /* enter interrupt */ rt_interrupt_enter(); - rt_tick_increase(); + if (LPC_RITIMER->CTRL & 0x01) + { + rt_tick_increase(); + LPC_RITIMER->CTRL |= 0x01; + } /* leave interrupt */ rt_interrupt_leave(); } +extern void SystemCoreClockUpdate(void); + /** * This function will initial LPC43xx board. */ void rt_hw_board_init() { + SystemCoreClockUpdate(); + + /* Setup RIT timer. */ + LPC_RITIMER->COMPVAL = SystemCoreClock / RT_TICK_PER_SECOND - 1; + /* Enable auto-clear. */ + LPC_RITIMER->CTRL |= 1 << 1; + /* Reset the counter as the counter is enabled after reset. */ + LPC_RITIMER->COUNTER = 0; + NVIC_SetPriority(M0_RITIMER_OR_WWDT_IRQn, (1 << __NVIC_PRIO_BITS) - 1); + NVIC_EnableIRQ(M0_RITIMER_OR_WWDT_IRQn); + /* set pend exception priority */ NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);