Microchip® Advanced Software Framework

Quick Start Guide for the MEGARF MACSC Driver

This is the quick start guide for the macscc_group , with step-by-step instructions on how to configure and use the driver for a specific use case.

The code examples can be used in the MAC stack to control super-frame timing or a generic application as a general pupose 32-bit timer/counter.

Use cases

MACSC overflow (interrupt based)

This use case will prepare the MACSC to trigger a interrupt when the timer overflows. The interrupt is handled by a customisable call back function.

We will setup the MACSC in this mode:

  • Use the system clock as clock source;provision to use the 32.768KHz clock is provided
  • Sleep and Automatic timestamping can be enabled as per application requirement
  • Overflow interrupt enable and callback

MACSC compare match (interrupt based)

Prequisites

For the setup code of this use case to work, the following must be added to the project:

MACSC compare match (interrupt based)

This use case will prepare the MACSC to trigger three independent interrupts when it reaches three different compare values. The three compare matches will be handled by three separate interrupts implemented in call back functions. Absolute compare mode of the MACSC is used. COMPARE_MODE in conf_example.h

We will setup the MACSC in this mode:

  • Use the system clock as clock source;provision to use the 32.768KHz clock is provided RTC_CLK_SRC in conf_example.h
  • Sleep and Automatic timestamping can be enabled as per application requirement
  • Compare match 1 interrupt triggers after quarter of a second
  • Compare match 2 interrupt trigger after half a second
  • Compare match 3 interrupt triggers after one second CONFIG_MACSC_TIMEOUT_TICK_HZ in conf_example.h

MACSC back off slot counter usage

(interrupt based)

This use case will prepare the MACSC to use the backoff slot counter module interrupt implemented in call back function.

We will setup the MACSC in this mode:

  • Use the system clock as clock source;provision to use the 32.768KHz clock is provided
  • Sleep and Automatic timestamping can be enabled as per application requirement ENABLE_SLEEP and ENABLE_AUTO_TIMESTAMP in conf_example.h
  • Back-off slot counter interrupt occurs every 320us(20 IEEE 802.15.4 symbol periods)

MACSC sleep-wakeup scheme (interrupt

based)

This use case will prepare the MACSC to use the relative compare mode to remain awake during the Contention Access Period(CAP) and required GTS of the superframe and sleep during the sleep period.All 3 compare modules are used along with Beacon Timestamp register. Ideally,Beacon Timestamp register is updated with SCCNT for every incoming IEEE802.15.4 frame. However,this application simulates the scenario by enable manual write of the Beacon Timestamp register to demonstrate relative compare. COMPARE_MODE in conf_example.h interrupts implemented in call back function.

We will setup the MACSC in this mode:

  • Use the system clock as clock source;provision to use the 32.768KHz clock is provided during sleep
  • Sleep and Automatic/Manual timestamping can be enabled as per application requirement ENABLE_SLEEP and ENABLE_AUTO_TIMESTAMP in conf_example.h
  • Set Beacon Interval and Superframe Interval as per application requirement.
  • In real networks,Superframe order and Beacon order are to be retrieved from incoming frame's header. BEACON_INTERVAL,ACTIVE_PERIOD,SLEEP_PERIOD in conf_example.h