Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC12F508 : OPTION Register issue ( Using HI-tech Compiler)

Status
Not open for further replies.
Hi building a trigger circuit, so I'am required to generate continuous on-off pulse from the Microcontroller. I' am using Internal clock through the following instruction :

__CONFIG(MCLRDIS & WDTDIS & UNPROTECT & INTRC);

Then I tried to configure Timer0.

So I did the following.

T0CS = 0 //Transition on internal instruction cycle clock, FOSC/4
PSA = 0 // Prescaler assigned to Timer0

PS0=1;PS1=1;PS2=1 // For maximum prescaler of 1:256

( Used the above, from the header file pic125xx.h as:
/* OPTION bits */
#define GPWU (1<<7)
#define GPPU (1<<6)
#define T0CS (1<<5)
#define T0SE (1<<4)
#define PSA (1<<3)
#define PS2 (1<<2)
#define PS1 (1<<1)
#define PS0 (1<<0)
)


But the compiler threw up an error , as :

Error [202] C:\Users\Chetan\Desktop\Yogesh\pulse.c; 10.11 only lvalues may be assigned to or modified


Couldn't understand where I went wrong. I' am new to Hi-tech compiler and trying to get used to it. Any kind of help will be greatly appreciated and would be of lot of help.



Thanks
Regards
Chetan Gowda
 
You are trying to give a constant a value which is not allowed.

Just write the whole register by doing, OPTION = 0b11000111;

Or, to set the prescaler do OPTION |= 0b00000111;

And to clear TOCS do OPTION &= ~TOCS;

HTH

Mike.
 
Status
Not open for further replies.

Latest threads

Back
Top