Good day, mister
mineiroIf you look that file "p12f508.inc" you will see a lot of EQUates like GPIO,OSCCAL as example.
EQU might mean EQUAL as well. It has a bit more sense in my head. FINE EQUAL 0x01
I think I understand this EQU thing now:
I imagine, that it may be a true CONSTANT. I've never used constants in my programming life, and what examples I've seen so far, they were mindless and meaningless.
But now, reading all this... I read your explanations, then I look in both Intel books, then I check 12f508.inc and indeed is full of EQU in it (I dont remember checking this file inside before)
I believe, that assignment name that we give: STATUS,GPIO,OSCCAL and your FINE example, they refer to -imutable- or -unchangeble- values H'0001' to H'0007' that are
fixed registers inside the processor or this PIC ram-memory-register.
Now, and only now, a constant has meaning for me ! That is something. Correct me if im wrong, of course.
After looking in p12f508.inc, what I trully dont understand is why W,INDF,C,PS0 EQU H'0000'. The same goes for those who EQU H'0001' up to EQU H'0007'
I understand perfectly they mean for ex: [NAME of] W EQUAL [BIT] H'0000' but the same goes for the other values.
What (code) is splitting them into registers to fit each specific register? Starting each from 0 to 7. I bet if you change the order of these lines, your compiler will shit itself with errors.
I would love to see the code that split and assign all these bits to their respective registers.
Or at least an interpretation (from your part) of that code, if the real code is buried inside compiler.
I think that "__config" line in source code is creating a binary number (byte) by seting/reseting some specific bits in 8 bits field.
I totally think that as well, and I did come across other codes (in my life) that were declaring __config as a set of bits something like b'01011010' for example.
So, "__config" line used AND (&) operator. You need probably check the meaning (equ) of _MCLRE_ON, _CP_OFF , _WDT_OFF , _IntRC_OSC
So this is homework for me, right? Haha, Yes, I like it.
By looking inside 12F508 datasheet (or manual), I find the Configuration Register that has 11bits in length but only the first 5 bits are active.
The rest, from bit 5 to bit 11, are NOT-implemented (gray out).
Image:
https://i.imgur.com/0u5aI8E.jpgThis is the part that I trully love about PIC's (and they made it so hard to see it with meaningless explanations of some weird stuff that is meant to derail you)
Every BIT counts! Haha. Meaning, you can actually count bits and they mean something both in real chip and in your code.
If we look on the table for Configuration Register inside datasheet, we can see the bit values for EVERY possible combination of configuration bits.
So, in our code, and I know this part very well, if let's say for example we have:
__config _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC
then it means:__config 1 1 0 10
and you can write it as: __config B'11010' and it means the same damn thing as __config _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC
But using only bit codes becomes very encripted, very quickly. It is very good to know this part because is helping your logic.
I know it helps me a lot to see things as they are.
Now, back to your example, I believe, what you mean with your q12config.inc is
FINE EQU B'11010' ;correct?
To only define this particular register bits, that is let's say [the most used] configuration in the large majority of my PICs.
I am right? I hope I am, because I learn something completly new with you today !
As always, thank you!