Electrical – getting an error when setting the TRIS registers with PIC

cmicrocontrollerpictri-state

I am new to PIC programming, and I am trying to blink an LED using the PIC10F206. It has 4 I/O pins. I understand I must declare them as inputs or outputs, but the IDE I am using (MPLAB) keeps giving me an error when I declare the TRIS register. Attached is a picture.

My Code with error indicator

The datasheet lists the TRIS GPIO register as having the name "TRISGPIO" but the compiler throws this error: "Unable to resolve identifier TRISGPIO".

Am I just getting the name of the TRIS register wrong? Attached is a picture of the TRIS GPIO register from the datasheet.
enter image description here

[EDIT]

Looks like it is a header file problem. When I highlight "xc.h", right click, and go to navigate -> go to definition, the xc.h file is pulled up but the code does not recognize my pic.h file which is where the header file for my chip is. See imagae for the xc.h screenshot.
enter image description here

I tried pointing to the directory in the compiler options but no luck. Any thoughts? Below is a picture of my compiler options

enter image description here

Best Answer

You are using a baseline PIC, so you can refer to the XC8 compiler User's Guide section 5.3.10:

5.3.10 Baseline PIC MCU Special Instructions The Baseline devices have some registers which are not in the normal SFR space and cannot be accessed using an ordinary file instruction. These are the OPTION and TRIS registers. Both registers are write-only and cannot be used in expression that read their value. They can only be accessed using special instructions which the compiler will use automatically. The definition of the variables that map to these registers make use of the control qualifier. This qualifier informs the compiler that the registers are outside of the normal address space and that a different access method is required. You should not use this qualifiers for any other registers

When you write to either of these SFR variables, the compiler will use the appropriate instruction to load the value. So, for example, to load the TRIS register, the following code: TRIS = 0xFF;

You will find the following definition in the relevant .h file for this chip:

// Register: TRISGPIO
#define TRISGPIO TRISGPIO
extern volatile __control unsigned char TRISGPIO            __at(0x006);

Which indeed contains the aforementioned __control qualifier. However it also defines TRISGPIO! And I tried a simple program and it does work if xc.h (which loads PIC10F206.h) is included, for either TRIS or TRISGPIO (MPLAB-X , XC8 V2.10).

You also have error markers beside your GPIO names, which implies your .h file is not being properly included or is missing something.

Edit: As @brhans mentions, make sure you've properly configured MPLAB-X for that exact chip. Your tree should look something like this:

enter image description here

If it's not properly configured it may be including the wrong file or nothing, I can't say as I've run into that issue myself.