Radio Controlled Timer, Step B

Goal
  • Add LEDs for debugging
  • Split source into  several source files

The 1829 configuration moved to a separate file “config_1829_RadioControlledSwitch.inc”

As there will be more .asm files added later, common parts moved to a separate file. As of Step A only the line #include “p16f1829.inc”.

Added file common_1829_RadioControlledTimer.inc and moved the include directive here

Also added radix dec to the file. Dec (decimal) is more natural to use than hex (hexadecimal), if a hex number is needed, I will use the H’xx’ notion. And the errorlevel -302 as MPASM throws a lot of messages about banking when using SFR registers.

LED

LED’s can be very helpful when debugging. Adding a RGB led will give, at least, 3 colors to use.

But now a pin usage list has to be created.

For every LED pin there will be 3 registers involved

  • ANSELx to select analogue/digital
  • TRISx to select input/output
  • LATx for output state

This means four definitions for every LED. It may seem a lot of definitions for just one LED but in the long run it simplifies a lot. Much easier to remember and if a LED has to be moved to another pin, only a few changes in one place needed.

LED handling created in a separate .asm file and a corresponding .inc file.

To verify LED handling a Delay routine added to main. The delay counters placed in common RAM.

From the logic analyser.

Code on Github

EDIT: 2018-10-15

Of course, 1829 ICSPDAT and ICSPCLK = pin 19 and pin 18

Schema changed!

 

Leave a Reply

Your email address will not be published. Required fields are marked *