Skip to content

Commit a67469f

Browse files
committed
more debugging
1 parent 9b0a361 commit a67469f

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

examples/nordic/nrf5x/src/blinky.zig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const uart = nrf.uart.num(0);
1010
pub const microzig_options = microzig.Options{
1111
.log_level = .debug,
1212
.logFn = nrf.uart.log,
13-
.interrupts = .{ .RTC0 = .{ .c = rtc_overflow_interrupt } },
13+
.interrupts = .{
14+
.RTC0 = .{ .c = rtc_overflow_interrupt },
15+
},
1416
};
1517

1618
pub fn main() !void {
@@ -27,7 +29,10 @@ pub fn main() !void {
2729
board.led1.toggle();
2830
std.log.info("Now: {}uS", .{time.get_time_since_boot().to_us()});
2931
std.log.info("period: {x}", .{time.period});
32+
std.log.info("INTENSET: {x:0>8}", .{microzig.chip.peripherals.RTC0.INTENSET.raw});
3033
std.log.info("Counter: {x:0>6}", .{microzig.chip.peripherals.RTC0.COUNTER.read().COUNTER});
34+
std.log.info("Interrupt en {}", .{microzig.cpu.interrupt.is_enabled(.RTC0)});
35+
std.log.info("Interrupt prio{}", .{microzig.cpu.interrupt.get_priority(.RTC0)});
3136
time.sleep_ms(500);
3237

3338
// board.led1.toggle();

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
///
22
/// Basic timekeeping for the nRF5x series MCUs.
33
///
4-
/// This module hogs TIMER0.
5-
/// It uses CC1 as the register to read the current count from.
4+
/// This module uses RTC0 and hogs CC[3]
65
/// It also sets up an interrupt to fire at certain values so that we are able to count them and
76
/// keep time for centuries.
87
const std = @import("std");
@@ -41,12 +40,17 @@ pub fn init() void {
4140
microzig.chip.peripherals.CLOCK.LFCLKSRC.modify(.{ .SRC = .RC });
4241
// Start LFCLK
4342
microzig.chip.peripherals.CLOCK.TASKS_LFCLKSTART.write_raw(1);
43+
microzig.cpu.interrupt.enable(.RTC0);
44+
microzig.cpu.interrupt.enable_interrupts();
45+
// microzip.cpu
4446

4547
// Enable interrupt firing on compare AND on overflow
46-
rtc.INTENSET.modify(.{
47-
.COMPARE3 = .Enabled,
48-
.OVRFLW = .Enabled,
49-
});
48+
rtc.INTENSET.write_raw(0x00080002);
49+
// rtc.INTENSET.modify(.{
50+
// // .TICK = .Enabled, // This triggers!
51+
// .COMPARE3 = .Enabled,
52+
// .OVRFLW = .Enabled,
53+
// });
5054
// Set the comparator to trigger on overflow of bottom 23 bits
5155
rtc.CC[COMPARE_INDEX].write(.{ .COMPARE = 0x8000 }); // DELETEME Just to not have to wait too
5256
// long for the interrupt to fire
@@ -86,6 +90,7 @@ pub fn rtc_overflow_interrupt() callconv(.c) void {
8690
std.log.info("compare!", .{}); // DELETEME
8791
next_period();
8892
}
93+
@panic("lol");
8994
}
9095

9196
inline fn next_period() void {

0 commit comments

Comments
 (0)