BlinkPlusAlarm

Overview

This example program is a variation of BlinkPlusRtk, with minimum changes to use an alarm interrupt handler to schedule a kernel thread, a feature promised for kernel v2, which does not work with kernel v1.

Description

The program is implemented using two modules:

  • BlinkPlusAlarmC0 for core 0
  • BlinkPlusAlarmC1 for core 1

The “functionality” is the same as for BlinkPlusRtk, but in lieu of using a non-blocking delay via the kernel, thread 0 on core 1 gets periodically scheduled by an alarm interrupt handler, BlinkPlusAlarmC1.trigger. The corresponding alarm device is initialised and enabled in BlinkPlusAlarmC1.Run.1

  • Initially, thread 0 sets up the alarm interrupt handler using Alarms.Arm.
  • Then, periodically, it does its blinky job, and suspends itself (BlinkPlusAlarmC1.t0c).
  • The alarm interrupt handler enables the thread and re-arms itself with the defined period using Alarms.Rearm.
  • Apart from writing its information the serial terminal, thread 0 now also prints the time between runs, so we can check if the alarm is firing on time.

Note that this is just a quick basic proof of concept. The kernel v2 is in prototype state, and needs more thought and work.

Output Terminals

See Set-up, two-terminal set-up.

Build and Run

Build module BlinkPlusAlarmC0 with Astrobe, and create and upload the UF2 file using abin2uf2.

Set Astrobe’s memory options as listed, and the library search path as explained. Requires kernel v2.

Repository


  1. No, you wouldn’t want to use an alarm for this purpose in a control program, it’s just a test. The kernel itself does just fine for period thread scheduling. ↩︎