Skip to content

Commit

Permalink
Added certainty in NRF51 clock startup.
Browse files Browse the repository at this point in the history
  * microbit/adainclude/nrf51_clock.adb: Wait until the high frequency
      clock is running.
  • Loading branch information
simonjwright committed Oct 9, 2022
1 parent 2b37668 commit 9fa6a83
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions microbit/adainclude/nrf51_clock.adb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ with System;
package body nRF51_Clock is

procedure Start is
use type nrf51.CLOCK.HFCLKSTAT_STATE_Field;
use type nrf51.CLOCK.LFCLKSTAT_STATE_Field;
begin

-- Wait until the high frequency clock is running (it should
-- start automatically, but ...)
loop
exit when nrf51.CLOCK.CLOCK_Periph.HFCLKSTAT.STATE =
nrf51.CLOCK.Running;
end loop;

-- Start the board low frequency clock, running off the high
-- frequency clock (which runs automatically).
--
Expand Down Expand Up @@ -153,6 +161,8 @@ package body nRF51_Clock is

-- Start the RTC tasks
nrf51.RTC.RTC1_Periph.TASKS_START := 1;

null;
end Start;

-- Startup has set up a weak RTC1_IRQHandler at interrupt 17.
Expand Down

0 comments on commit 9fa6a83

Please sign in to comment.