HWA
Bare metal programming with style
Class _ctb: 8-bit counter with two compare units and one dead-time generator

This class is used by:

Relatives

Interrupts

Actions



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

hwa( configure, counter0,
// How the counter is clocked
//
clock, none // No clock, counter stopped
| ioclk [/ 2**(0..14)] // IOCLK divided by 1,2,4,..16384
[ direction, up_loop, ] // Default, no other choice
[ bottom, 0, ] // Default, no other choice
// The maximum value the counter reaches
//
[ top, 0xFF | 0x00FF | 255 | max // Hardware fixed value 0xFF (default)
| compare2, ] // Value stored in compare2
// When the overflow flag is set
//
[ overflow, after_bottom ] // When the counter restarts from 0
);
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.



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 );

Internals

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