1
\$\begingroup\$

I'm brand new to any microcontroller programming and am playing around with the PIC10F200. I'm using MPLAB X 5.45 with XC8 2.32 pic-as compiler and I saw that most of the registers have constants declared in the .inc file associated with this chip (STATUS, TMR0, OSCCAL, GPIO, etc). Is there any reason that the OPTION register doesn't have constants (like T0CS) declared in either the .inc file or the .h file for the PIC10F200?

Link to PIC10F200 datasheet. Table 5-2 shows the OPTION register bits.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Quote from the datasheet:

The OPTION register is a 8-bit wide, write-only register, which contains various control bits to configure the Timer0/WDT prescaler and Timer0. By executing the OPTION instruction, the contents of the W register will be transferred to the OPTION register.

Thus, the OPTION register is not mapped into memory and thus has no memory address (The constants in the include files are the memory addresses of the respective registers, so you can access them by name). It is written by loading the value to write into W and executing the OPTION instruction.

\$\endgroup\$
3
  • \$\begingroup\$ Right, I get that I can execute ~(1 << 0005h) and then execute OPTION to clear the T0CS bit, but when I write ~(1 << T0CS), there is no T0CS constant defined in the include files. Is this named something different? The pic10f200.inc file is fairly short and I've gone through it a few times. \$\endgroup\$ Mar 24, 2021 at 15:18
  • \$\begingroup\$ @NathanielMurphy they are defined in the C include file <pic10f200.h> - weird that they're missing from the assembler include... \$\endgroup\$
    – brhans
    Mar 24, 2021 at 15:35
  • 1
    \$\begingroup\$ @brhans It is preferred to include xc.h instead of a specific picxxxxx.h. This will then include all the necessary files automatically. \$\endgroup\$
    – vini_i
    Mar 24, 2021 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.