A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
"newbie" C problem using ht-ide and PICC - =?ISO-8859-1?Q?Benjamin_S=F8lberg?= - Sep 8 8:04:54 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
#include
__CONFIG(INTRC & WDTDIS & UNPROTECT & MCLRDIS);
#define C1 GP0
#define C2 GP1
#define C3 GP2
#define L GP3
#define R GP4
#define c1 GP5
void main(void)
{
TRIS =3D 0b00011111;
while (1=3D=3D1) {
GP5 =3D GP0 | GP1; <- this doesn't compile
GP5 =3D GP0 || GP1; <- this doesn't work
}
}
--=20
Med venlig hilsen/ Best regards
Benjamin S=F8lberg/JavaDesign
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instruction=
s

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: "newbie" C problem using ht-ide and PICC - cdb - Sep 12 0:51:52 2008
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.
while(1)
{ 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
Hilse
Colin
--
cdb, c...@btech-online.co.uk on 12/09/2008
Web presence: www.btech-online.co.uk
Hosted by: www.1and1.co.uk/?k_id=7988359
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )