HWA
Bare metal programming with style
Class _ctc: 8-bit counter with two compare units

This class is used by:

Note
Currently, this class is not fully implemented. It lacks asynchronous clocking possibilities.

The only difference between this class and the _cta class is the different clocking possibilities.

Relatives

Interrupts

Actions



hwa( configure, ... ): configure the counting unit

hwa( configure, counter0,
// How the counter is clocked
//
clock, none // No clock, the counter is stopped
| ioclk [/ 8|32|64|128 // IOCLK divided by 1,8,32,64...
|256|512|1024] //
| external_xosc, // Crystal between pins TOSC1-TOSC2
// How does this counter count
//
direction, up_loop // Count from bottom to top and loop
| updown_loop, // Count up and down alternately
[ bottom, 0, ] // Default, no other choice
// The maximum value the counter reaches
//
[ top, 0xFF | 0x00FF | 255 | max // Hardware fixed value 0xFF (default)
| compare0, ] // Value stored in compare0
// When the overflow flag is set
//
[ overflow, after_bottom // When the counter resets to bottom
| after_top // When the counter reaches the top value
| after_max ] // When the counter reaches its max value
);
Note
If a compare unit is used, its configuration must be done inside the same context as the counter so that HWA has all the necessary informations to choose the correct register settings.
If the optionnal argument overflow is not stated, an acceptable value will be selected according to the configuration of the compare units found in the HWA context. If overflow is stated, the validity of its value will be verified.



hw( read, ... ): get the count

uint8_t n = hw( read, counter0 );



hw( write, ... ), hwa( write, ... ): set the count

hw( write, counter0, value );
hwa( write, counter0, value );

Registers

Hardware registers:

Logical registers:

hwa
#define hwa(...)
hwa( action, object [,...] ) stores an action for an object into a HWA context.
Definition: hwa_macros.h:552
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523