"newbie" C problem using ht-ide and PICC

Started by September 8, 2008
Hi all

First if this post doesn't conform to standart, then please bare with me.
This is my first post here.

Now to the problem.

I am using Hi-TECH PICC to make a small c program using a pic 12f508
(which i had laying around).
But just ran into a few problems. I am sure that they are all an
"Error 40" (40 cm in front of the screen)-

I get compiler errors while doing a little boolean/bitwise stuff.
Right here i am just trying to OR GP0 and GP1 and then placing the
resulting bit bit5 on GP5.

Anyone have any clood



#define C1 GP0
#define C2 GP1
#define C3 GP2
#define L GP3
#define R GP4
#define c1 GP5

void main(void)
TRIS = 0b00011111;
while (1==1) {
GP5 = GP0 | GP1; <- this doesn't compile
GP5 = GP0 || GP1; <- this doesn't work

Med venlig hilsen/ Best regards
Benjamin Sberg/JavaDesign

to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
Heg Benjamin,

First of all TRIS should be TRISA or TRISB, TRISC etc, depending on
which port you are wanting to use and Pic part.

:: void main(void)
:: {
:: TRIS = 0b00011111;

Second, I'm not sure the compiler would allow you to OR two pins
together as you have done. I suggest trying

void main(void)

TRISB = 0b00011111; //I've used portB, change to whatever port.

{ unsigned char port_result;

port_result = GP0 | GP1;

GP5 = GP5 | port_result;

The other type of OR ( || ) is used if you want to have something like

if (GP3 || GP2 == 1) meaning if either GP3 or GP2 = 1


cdb, c...@btech-online.co.uk on 12/09/2008

Web presence: www.btech-online.co.uk

Hosted by: www.1and1.co.uk/?k_idy88359