Hello Serge,
On second thoughts, the resources of the KA2 device are so limited, that if you wish to program in C, the coding will need to be very direct. "Encapsulation" is probably something you cannot afford in this case, because of the extra resources it will consume.
It is debatable whether this device should even be coded using C.
#define LED2 PTAD_PTAD5
void main () {
....
....
...
if (cmpt < inc)
LED2 = ON;
else
LED2 = OFF;
....
}
This is likely to produce minimal code size, with minimum RAM usage. Since the KA2 has no stack, and is limited to one nesting level for sub-routines, additional overheads will be required to allocate local variables, and for additional levels of nested C functions. For sufficiently compact code, you will need to minimize the use of variables, and the nesting of functions.
Regards,
Mac