Skip to content

Commit 9b0a361

Browse files
committed
debugging
1 parent 08e8f45 commit 9b0a361

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

examples/nordic/nrf5x/src/blinky.zig

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@ pub fn main() !void {
2525

2626
while (true) {
2727
board.led1.toggle();
28-
std.log.info("Now: {}", .{time.get_time_since_boot()});
28+
std.log.info("Now: {}uS", .{time.get_time_since_boot().to_us()});
29+
std.log.info("period: {x}", .{time.period});
30+
std.log.info("Counter: {x:0>6}", .{microzig.chip.peripherals.RTC0.COUNTER.read().COUNTER});
2931
time.sleep_ms(500);
3032

31-
board.led1.toggle();
32-
board.led2.toggle();
33-
std.log.info("Now: {}", .{time.get_time_since_boot()});
34-
time.sleep_ms(500);
35-
36-
board.led2.toggle();
37-
board.led3.toggle();
38-
std.log.info("Now: {}", .{time.get_time_since_boot()});
39-
time.sleep_ms(500);
33+
// board.led1.toggle();
34+
// board.led2.toggle();
35+
// std.log.info("Now: {}", .{time.get_time_since_boot()});
36+
// time.sleep_ms(500);
37+
//
38+
// board.led2.toggle();
39+
// board.led3.toggle();
40+
// std.log.info("Now: {}", .{time.get_time_since_boot()});
41+
// time.sleep_ms(500);
4042
}
4143
}

port/nordic/nrf5x/src/hal/time.zig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const TIMER_BITS = 23;
2727

2828
// Must use @atomic to load an store from here.
2929
/// Stored the high bits of the current time, giving us 55 (23+32) instead of just 24 bits
30-
var period: u32 = 0;
30+
pub var period: u32 = 0;
3131

3232
pub fn init() void {
3333
// We only use 23 of 24 bits of the RTC to avoid a race condition where time_since_boot() is
@@ -48,7 +48,9 @@ pub fn init() void {
4848
.OVRFLW = .Enabled,
4949
});
5050
// Set the comparator to trigger on overflow of bottom 23 bits
51-
rtc.CC[COMPARE_INDEX].write(.{ .COMPARE = 0x800000 });
51+
rtc.CC[COMPARE_INDEX].write(.{ .COMPARE = 0x8000 }); // DELETEME Just to not have to wait too
52+
// long for the interrupt to fire
53+
// rtc.CC[COMPARE_INDEX].write(.{ .COMPARE = 0x800000 });
5254

5355
// Clear counter, then start timer
5456
switch (version) {
@@ -75,11 +77,13 @@ pub fn init() void {
7577
pub fn rtc_overflow_interrupt() callconv(.c) void {
7678
if (rtc.EVENTS_OVRFLW.raw == 1) {
7779
rtc.EVENTS_OVRFLW.raw = 0;
80+
std.log.info("overflow!", .{}); // DELETEME
7881
next_period();
7982
}
8083

8184
if (rtc.EVENTS_COMPARE[COMPARE_INDEX].raw == 1) {
8285
rtc.EVENTS_COMPARE[COMPARE_INDEX].write_raw(0);
86+
std.log.info("compare!", .{}); // DELETEME
8387
next_period();
8488
}
8589
}

0 commit comments

Comments
 (0)