I love controlling machines. And the closest - most native - language of machines is assembly.
Microchip's many chips and many dialects afford a wonderful experience to the programmer.
These and Those...
Microchips PICs
Windowed and Flash
UV erasable and In Circuit Serial Programmable (ICSP)
Here is something to look out for; something NOT to do...
Here is a bit of code that works on some chips and in some circuits.
It simply flashed an LED on and off. But the key problem, is that the port was defined as an OUTPUT with
the Trisb register, and it is a little known fact that the port can still be read. Don't do it!
The circuit worked fine for a PIC16F1933 (with Latx), but not for a PIC16F886.
Also works for PIC16C73 (without Latx). The btfss is reading the literal
pin voltage, NOT the logic state. How fast that voltage decays off is problematic.
For chips without the Latx,
You should use Trisx to
define the port function, and keep your boys as boys, and your girls as girls.
I could even digress a little further...
The circuit could even depend on ambient light!!!
Now, how in the hell did you get that? The circuit is whimsical enough without you throwing in LIGHT too!
The circuit is reading the voltage on the pin. The pin is connected to an LED. Now hang on...
Normally, an LED is used to produce light, but the same physics that produce light from current can
also do the reverse: produce current from light. Take an LED over to some sunlight, and you will see.
Aliases...
Here is something that I discovered by accident. You may benefit too.
If you have a variable that is not dedicated to any one parameter. You can create aliases that make its
name more user friendly.
All of these names, ApplesVAR, OrangesVAR, GrapesVAR, and THayYerL, go to the same address: DummyHi1.
And, they do not take up any extra data memory.
A BCD to Hex Converter...
TDayYerH:TDayYerL is dual register pair that represents a BCD value.
THayYerH:THayYerL is dual register that represents pure Hex.
Lines 15 and 16
Relate to the fact that no conversion is necessary for the low byte. It is simply copied in.
Time code from Ft Colins, Colorado uses a BCD on the high byte:
If bit0 is set then 100 (decimal) is added to the low byte.
If bit1 is set then 200 (decimal) is added to the low byte.
If both bits are set then 300 (decimal) is added to the low byte.
More than 365 Days are possible.
Line 21:
You do not have to use Hex, you can use D'100'; it still works...
Lines 8 to 11:
Use MPLab to quickly check out all possible values.
Retrieve Data from Program Memory...
The Program Memory is setting here: H(0D:00)
Line 25:
You do not have to multiply by two in your case.
I just choose to read in 4 bytes, two words, at a time.
The data represents 14bits per word. And, for me, each word is two varibles.