Searching \ for '[PIC] C issue' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/microchip/languages.htm?key=c
Search entire site for: 'C issue'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] C issue'
2011\06\06@115311 by PICdude

flavicon
face
Decided to (finally) tinker with C programming this weekend, and using  the default install of Hi-Tech C (Lite) that came with MPLAB 8.66.

I created a basic piece of code to turn on some LED's (multiplexed  discrete and 7-segment) on an existing board I have, and it takes a  LONG time to start up -- in the order of several minutes, if at all.   One a couple occasions it worked right away.  So I'm guessing the  oscillator is not starting up properly...?

I also tried setting the config bits from the Config Bits menu rather  than the code and it worked (code ran immediately on programming) the  first time, but I can't reproduce that any more.

Also tried explicitly turning on Vdd and releasing from reset, but no  difference.  And the board works perfectly with assembly code.

What am I missing here?  For reference, this is the code I'm using (16F883)....



#include <pic.h>

__CONFIG(1, FOSC_INTRC_NOCLKOUT & DEBUG_OFF & WDTE_OFF & LVP_OFF &  BOR_ON & CP_OFF & CPD_OFF & FCMEN_ON & IESO_ON & MCLRE_OFF & PWRTE_ON);
__CONFIG(2, BOR4V_BOR40V & WRT_OFF);

#define FOSC 8000000L                        /* 8 Mhz internal clock */

void main(void)
{
       INTCON = 0;

       OSCCON = 0x71;                                /* 8 Mhz internal clock */

       TRISA = 0b00001011;
       TRISB = 0b11100000;
       TRISC = 0b00000000;                        /* PORTC is all outputs */

       ANSEL = 0b00000011;                        /* RA0,1 are analog inputs */
       ANSELH = 0;
       ADCON1 = 0b00010000;                /* Left justified, External Vref+ */

       OPTION_REG = 0;                                /* Port-B pullups active */
       WPUB = 0b01100000;

       VRCON = 0;                                        /* Turn off */
       T1CON = 0;
       CM1CON0 = 0;
       CM2CON0 = 0;
       CM2CON0 = 0x02;                                /* Turn off comparators */

       PORTA = 0b11111111;                        /* Turn on all columns */
       PORTB = 0b11111111;                        /* Turn on all rows */
       PORTC = 0b10101010;                        /* Turn on all rows */

/* TODO -- testing... just stop here for now */
       for        (;;)
       {
       }
}


Cheers,
-Neil.


2011\06\06@123317 by Oli Glaser

flavicon
face
On 06/06/2011 16:52, PICdude wrote:
> What am I missing here?  For reference, this is the code I'm using (16F883)...
>
>

Are you sure the config bits are right?
I just checked in the include file for the 16F883 I have for an early version of PICC I have on here (9.70) and for the internal oscillator (no clock out) you put INTCLK.
In case you don't know, all the bits are defined in install directory->include->pic16f887.h (right at the bottom)

2011\06\06@123712 by Andre Abelian

picon face
Neil,

just to test add external crystal and turn off internal also turn off brawn out reset.
see what happens.
AA




________________________________
From: PICdude <spam_OUTpicdude3TakeThisOuTspamnarwani.org>
To: .....piclistKILLspamspam@spam@MIT.EDU
Sent: Mon, June 6, 2011 8:52:55 AM
Subject: [PIC] C issue

Decided to (finally) tinker with C programming this weekend, and using  the default install of Hi-Tech C (Lite) that came with MPLAB 8.66.

I created a basic piece of code to turn on some LED's (multiplexed  discrete and 7-segment) on an existing board I have, and it takes a  LONG time to start up -- in the order of several minutes, if at all.  One a couple occasions it worked right away.  So I'm guessing the  oscillator is not starting up properly...?

I also tried setting the config bits from the Config Bits menu rather  than the code and it worked (code ran immediately on programming) the  first time, but I can't reproduce that any more.

Also tried explicitly turning on Vdd and releasing from reset, but no  difference.  And the board works perfectly with assembly code.

What am I missing here?  For reference, this is the code I'm using (16F883)....



#include <pic.h>

__CONFIG(1, FOSC_INTRC_NOCLKOUT & DEBUG_OFF & WDTE_OFF & LVP_OFF &  BOR_ON & CP_OFF & CPD_OFF & FCMEN_ON & IESO_ON & MCLRE_OFF & PWRTE_ON);
__CONFIG(2, BOR4V_BOR40V & WRT_OFF);

#define FOSC 8000000L            /* 8 Mhz internal clock */

void main(void)
{
   INTCON = 0;

   OSCCON = 0x71;                /* 8 Mhz internal clock */

   TRISA = 0b00001011;
   TRISB = 0b11100000;
   TRISC = 0b00000000;            /* PORTC is all outputs */

   ANSEL = 0b00000011;            /* RA0,1 are analog inputs */
   ANSELH = 0;
   ADCON1 = 0b00010000;        /* Left justified, External Vref+ */

   OPTION_REG = 0;                /* Port-B pullups active */
   WPUB = 0b01100000;

   VRCON = 0;                    /* Turn off */
   T1CON = 0;
   CM1CON0 = 0;
   CM2CON0 = 0;
   CM2CON0 = 0x02;                /* Turn off comparators */

   PORTA = 0b11111111;            /* Turn on all columns */
   PORTB = 0b11111111;            /* Turn on all rows */
   PORTC = 0b10101010;            /* Turn on all rows */

/* TODO -- testing... just stop here for now */
   for    (;;)
   {
   }
}


Cheers,
-Neil.


2011\06\06@134456 by PICdude

flavicon
face
Yep, I got it from C:\Program Files\HI-TECH  Software\PICC\9.81\include.  There is also a directory for 9.80, but  that did not have the F883, so I used the include from the 9.81  directory.  And the executable is C:\Program Files\HI-TECH  Software\PICC\9.81\bin\picc.exe  anyway.

The include file defines "CONFIG1", but not sure where I should use  that.  I found the syntax of __CONFIG (1, ...) from an online example.    And why would it not work if I tell it to use the config bits from  the menu/manual selector rather than the code?

Cheers,
-Neil.



Quoting Oli Glaser <oli.glaserspamKILLspamtalktalk.net>:

{Quote hidden}

>

2011\06\06@134610 by PICdude

flavicon
face
For now I can't do that -- no crystals where I'm at, and this board is  not setup for a crystal anyway.  It's a custom board I was using to  develop another app.

Cheers,
-Neil.


Quoting Andre Abelian <.....abelian.andreKILLspamspam.....yahoo.com>:

{Quote hidden}

>

2011\06\06@135910 by Bob Blick

face
flavicon
face
Hi Neil,

My guess is the CONFIG statements are wrong. HiTech has changed the
format of them at least four times in my memory. It's also pretty much
left to the user to figure out.

In the old version I use you would not have the "1" and "2". Just having
the statements on separate lines is what it wants. But that's my old
version.

Cheers,
Bob

On Mon, 06 Jun 2011 08:52 -0700, "PICdude"  wrote:

>
> __CONFIG(1, FOSC_INTRC_NOCLKOUT & DEBUG_OFF & WDTE_OFF & LVP_OFF &  
> BOR_ON & CP_OFF & CPD_OFF & FCMEN_ON & IESO_ON & MCLRE_OFF & PWRTE_ON);
> __CONFIG(2, BOR4V_BOR40V & WRT_OFF);

-- http://www.fastmail.fm - The way an email service should be

2011\06\06@140216 by Tamas Rudnai

face picon face
On Mon, Jun 6, 2011 at 5:32 PM, Oli Glaser <@spam@oli.glaserKILLspamspamtalktalk.net> wrote:

> Are you sure the config bits are right?
> I just checked in the include file for the 16F883 I have for an early
> version of PICC I have on here (9.70) and for the internal oscillator
> (no clock out) you put INTCLK.
>

Just as a side note: Since Microchip acquired HiTech, some names and defines
changed in the header files, so old projects would not compile at all. Many
people actually turnes off from PICC because of that (no reason changing
these without backward compatibility).

Tamas




> In case you don't know, all the bits are defined in install
> directory->include->pic16f887.h (right at the bottom)
>
>
>
>

2011\06\06@140312 by PICdude

flavicon
face
Okay, my bad (which I never doubted anyway), and it's now solved.  I  just noticed a warning that the "__CONFIG(1, ...)" line(s) had an  error.  Found in the manual that I just need to use "__CONFIG(...)"  twice in a row and it will sequentially assign each to the correct  config register (so I don't have to explicitly differentiate between  the two, other than putting them in the correct order).

Cheers,
-Neil.



Quoting PICdude <KILLspampicdude3KILLspamspamnarwani.org>:

{Quote hidden}

>> -

2011\06\06@140910 by Oli Glaser

flavicon
face
On 06/06/2011 18:44, PICdude wrote:
> Yep, I got it from C:\Program Files\HI-TECH
> Software\PICC\9.81\include.  There is also a directory for 9.80, but
> that did not have the F883, so I used the include from the 9.81
> directory.  And the executable is C:\Program Files\HI-TECH
> Software\PICC\9.81\bin\picc.exe  anyway.
>
> The include file defines "CONFIG1", but not sure where I should use
> that.  I found the syntax of __CONFIG (1, ...) from an online example.
>    And why would it not work if I tell it to use the config bits from
> the menu/manual selector rather than the code?
>

Right, I see, you're using PICC 9.81 (I mistakenly thought you were using an early version)
According to my include file (for the 883) it is FOSC_INTRC_CLKOUT
They are all defined at the top of the file.
I wouldn't put that 1 and 2 at the start of the arguments, what are they for?
I'm pretty sure last time I read the PICC manual it said just to put the config 1 and 2 (if more than one register) in order and it will know which one is which.
It should work if you set the config bits in MPLAB though, so it looks like there is another problem.
Does it work in MPLAB SIM?

2011\06\06@141703 by Oli Glaser

flavicon
face
Try this, I changed the 1 and 2 and BOREN from your original. Looks okay compared to the config bits in my file.

__CONFIG(FOSC_INTRC_NOCLKOUT&  DEBUG_OFF&  WDTE_OFF&  LVP_OFF&
BOREN_ON&  CP_OFF&  CPD_OFF&  FCMEN_ON&  IESO_ON&  MCLRE_OFF&  PWRTE_ON);
__CONFIG(BOR4V_BOR40V&  WRT_OFF);

I don't know if you are debugging or not, but you might want to set DEBUG_ON or DEBUG_OFF accordingly in config 1.


2011\06\06@143518 by PICdude

flavicon
face
Yep, that's exactly what I figured out, and it works now.



Quoting Bob Blick <spamBeGonebobblickspamBeGonespamftml.net>:

{Quote hidden}

>

2011\06\06@143934 by PICdude

flavicon
face
Yep, saw that in the manual, and all works now.  The "(1," and "(2," I  had found online.  However, I'm bugged that it does NOT ignore the  config lines in the code, even if I tell it to use the ones from the  menu/manual settings.

Cheers,
-Neil.



Quoting Oli Glaser <TakeThisOuToli.glaserEraseMEspamspam_OUTtalktalk.net>:

{Quote hidden}

>

2011\06\06@144823 by PICdude

flavicon
face
Wasn't aware that Microchip acquired HiTech, but for the 16F and  enhanced 16F, is there any better option?  I'm tinkering for now, but  will prob want optimizations at some point and wondering if there's a  better less-than-$1200 option out there.  Especially since I  understand that the 16F version is limited to the 16F, and if I want  to use if for the 18F or 24F, I have to buy additional versions for  those.

Cheers,
-Neil.


Quoting Tamas Rudnai <RemoveMEtamas.rudnaispamTakeThisOuTgmail.com>:

> Just as a side note: Since Microchip acquired HiTech, some names and defines
> changed in the header files, so old projects would not compile at all. Many
> people actually turnes off from PICC because of that (no reason changing
> these without backward compatibility).
>
> Tamas

2011\06\06@150447 by Denny Esterline
picon face
>
> Wasn't aware that Microchip acquired HiTech, but for the 16F and
> enhanced 16F, is there any better option?  I'm tinkering for now, but
> will prob want optimizations at some point and wondering if there's a
> better less-than-$1200 option out there.  Especially since I
> understand that the 16F version is limited to the 16F, and if I want
> to use if for the 18F or 24F, I have to buy additional versions for
> those.
>
> Cheers,
> -Neil.
>
>
This is dangerously close to the age old religious debate of "which is
better". It's been hashed over many, many times and I doubt another cycle is
going to find any better answers...

I use the CCS compiler (CCSinfo.com). The price is better than most. I'm
sure some people will swear by it, others will swear at it. I've managed to
use it in projects that sold, so it can't be all bad.

-Denn

2011\06\06@150612 by Oli Glaser

flavicon
face
On 06/06/2011 19:37, PICdude wrote:
>   However, I'm bugged that it does NOT ignore the
> config lines in the code, even if I tell it to use the ones from the
> menu/manual settings.

Glad that it's working :-)
You may already know/have tried the following, but just in case:
With the above, did you recompile after you set the bits in the settings?
If I remember right, you just have to program after setting them, rather than rebuild and program.
You get that pop up box telling you that the settings will override your code *until* you rebuild the project.

2011\06\06@152246 by Bob Blick

face
flavicon
face
On Mon, 06 Jun 2011 11:47 -0700, "PICdude"  wrote:
> better less-than-$1200 option out there.
CCS

Cheers, Bob

-- http://www.fastmail.fm - Accessible with your email software
                         or over the web

2011\06\06@161445 by Tamas Rudnai

face picon face
I would evaluate SoureBoost as well as ByteCraft MPC. Not sure about the
pricing and if any of these would meet your requirements, but speak to them
and give them a go.

Tamas




On Mon, Jun 6, 2011 at 7:47 PM, PICdude <picdude3EraseMEspam.....narwani.org> wrote:

{Quote hidden}

>

2011\06\06@180608 by PICdude

flavicon
face
True.  And prob worse is that I'm sure I've been in a couple of those  discussions, so I'll quietly fade away now...

Cheers,
-Neil.



Quoting Denny Esterline <RemoveMEdesterlineEraseMEspamEraseMEgmail.com>:

> This is dangerously close to the age old religious debate of "which is
> better". It's been hashed over many, many times and I doubt another cycle is
> going to find any better answers...

2011\06\06@180747 by PICdude

flavicon
face
If, as it seems, I can run the command-line version from inside MPLAB  IDE, then a couple hundred bucks for 16-bit PICs is nice.  Will  investigate further.

Cheers,
-Neil.


Quoting Bob Blick <RemoveMEbobblickspam_OUTspamKILLspamftml.net>:

> On Mon, 06 Jun 2011 11:47 -0700, "PICdude"  wrote:
>> better less-than-$1200 option out there.
>
> CCS
>
> Cheers, Bob

2011\06\07@155130 by Gerhard Fiedler

picon face
Bob Blick wrote:

> It's also pretty much left to the user to figure out.

That's right. OTOH, looking at the appropriate section in the processor
include file, the respective pages in the processor manual, and the
examples that come with your compiler version (not the internet :), you
can't go too wrong.

Gerhar

2011\06\07@173814 by Bob Blick

face
flavicon
face
On Tue, 07 Jun 2011 16:51 -0300, "Gerhard Fiedler" wrote:
>
> > It's also pretty much left to the user to figure out.
>
> That's right. OTOH, looking at the appropriate section in the processor
> include file, the respective pages in the processor manual, and the
> examples that come with your compiler version (not the internet :), you
> can't go too wrong.

No, in fact _my_ PICC manual says nothing about the second __CONFIG
macro line. Back when I needed to know I had to search the HiTech forum
to find it. On the internet :) There have been changes to the manual
since, but the change to the __CONFIG macro was a fairly silent
introduction. That's the way HiTech has always handled updates, with
great email support and out-of-date manuals. The examples that came with
the compiler are for old PICs that do not have Config 2. And include
files have the definitions of the fuses, not the syntax of the macros
that use them. I've been using HiTech since it was beta, so I'm fairly
familiar with how their products have evolved and what to do when
upgrades break stuff. I don't own any of their new products, but it
wouldn't surprise if their documentation hasn't improved. That isn't why
people buy their products, but it's probably why some people don't.

Bob

-- http://www.fastmail.fm - Same, same, but different...

2011\06\08@075715 by Gerhard Fiedler

picon face
Bob Blick wrote:

> On Tue, 07 Jun 2011 16:51 -0300, "Gerhard Fiedler" wrote:
>>
>>> It's also pretty much left to the user to figure out.
>>
>> That's right. OTOH, looking at the appropriate section in the
>> processor include file, the respective pages in the processor
>> manual, and the examples that come with your compiler version (not
>> the internet :), you can't go too wrong.
>
> No, in fact _my_ PICC manual says nothing about the second __CONFIG
> macro line.
You say at least two things here; one that I can agree with, and one
that just doesn't make sense.
"in fact _my_ PICC manual says nothing about the second __CONFIG macro
line": That may well be, and AIUI I said as much when I started my
comment with "that's right".
"No": No what? Between "processor include file", "processor manual" and
"example code" I don't see how what the PICC manual says or doesn't say
has anything to do with what I wrote.

Maybe it's just the expression of a negative predisposition?

Gerhar

2011\06\08@114540 by Bob Blick

face
flavicon
face
On Wed, 08 Jun 2011 08:57 -0300, "Gerhard Fiedler" wrote:

> Maybe it's just the expression of a negative predisposition?

No, unlike some people, I'm only a dick when I want to be.

Is that satisfactory or would you like some more?

Bob

-- http://www.fastmail.fm - Choose from over 50 domains or use your own

2011\06\08@124251 by Gerhard Fiedler

picon face
Bob Blick wrote:

> On Wed, 08 Jun 2011 08:57 -0300, "Gerhard Fiedler" wrote:
>
>> Maybe it's just the expression of a negative predisposition?
>
> No, unlike some people, I'm only a dick when I want to be.

Well, you stated here that this is not a reason for the "no", but you
didn't really provide the reason why you wrote it. Rather than an
attitude, a reason would go a long way.

> Is that satisfactory or would you like some more?

If you have anything to say about the actual issue, that might be more
satisfactory than this here -- but I'm sure you knew this before I wrote
it. (To answer your question, you'd of course have to be a tad clearer
about what you mean with "some more".)

Gerhar

2011\06\08@125817 by Bob Blick

face
flavicon
face
On Wed, 08 Jun 2011 13:42 -0300, "Gerhard Fiedler" wrote:

> > On Wed, 08 Jun 2011 08:57 -0300, "Gerhard Fiedler" wrote:
> >
> >> Maybe it's just the expression of a negative predisposition?
> If you have anything to say about the actual issue, that might be more
> satisfactory than this here -- but I'm sure you knew this before I wrote
> it. (To answer your question, you'd of course have to be a tad clearer
> about what you mean with "some more".)

I'm not asking for an apology, if you'd just shut up that'd be fine.

In the future, if you want to send me insults, do it off-list.

Bob

-- http://www.fastmail.fm - mmm... Fastmail...

2011\06\08@130131 by Gerhard Fiedler

picon face
Bob Blick wrote offlist:

> I don't know why you bother to write me on list.

I don't really write "you" onlist. I write to the list.
> Do you even use Hi-Tech PICC for the 16F series?

Not currently a lot, but yes, I do have a license for quite a few years,
through quite a few versions (even though not the latest), and I used it
in a few projects over the years.

And since we're in questioning: Did you read what I wrote before
responding? All three responses of yours seem to indicate that you
didn't, at least not completely and/or thoroughly.

I wrote:
: OTOH, looking at the appropriate section in the processor include
: file, the respective pages in the processor manual, and the examples
: that come with your compiler version (not the internet :), you can't
: go too wrong.

You answered "no", followed by a reason that has nothing to do with what
I wrote, and when I asked why "no" you answered with off-topic stuff of
the personal nature that generally admins make it their job to stop (but
of course not in this case...) -- and again what you wrote didn't have
much to do with what I wrote.
I understand that you are using this compiler a lot, and actively, so of
course it would be interesting if you had anything to say about what I
actually wrote.

Gerhar

2011\06\08@130223 by Dwayne Reid

flavicon
face
Hey Bob!

You forgot the <VBG> at the end of your last sentence!

Couldn't resist replying - this was a well-timed moment of levity for me.

dwayne


At 09:45 AM 6/8/2011, Bob Blick wrote:
{Quote hidden}

-- Dwayne Reid   <RemoveMEdwaynerTakeThisOuTspamspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax
http://www.trinity-electronics.com
Custom Electronics Design and Manufacturing

2011\06\08@131055 by Dwayne Reid

flavicon
face
At 10:42 AM 6/8/2011, Gerhard Fiedler wrote:
>Bob Blick wrote:
>
> > On Wed, 08 Jun 2011 08:57 -0300, "Gerhard Fiedler" wrote:
> >
> >> Maybe it's just the expression of a negative predisposition?
> >
> > No, unlike some people, I'm only a dick when I want to be.
>
>Well, you stated here that this is not a reason for the "no", but you
>didn't really provide the reason why you wrote it. Rather than an
>attitude, a reason would go a long way.
>
> > Is that satisfactory or would you like some more?
>
>If you have anything to say about the actual issue, that might be more
>satisfactory than this here -- but I'm sure you knew this before I wrote
>it. (To answer your question, you'd of course have to be a tad clearer
>about what you mean with "some more".)

Whoa!  Stop!

I wrote a few minutes ago saying that I thought that Bob's remark was meant to be funny - and I still do.

But I now can see that it might be taken as offensive.  I'm pretty sure that was not the intent but . . .

I'm not an admin, but can I respectfully suggest that this stop right now?

Thanks!

dwayne

-- Dwayne Reid   <EraseMEdwaynerspamspamspamBeGoneplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax
http://www.trinity-electronics.com
Custom Electronics Design and Manufacturing

More... (looser matching)
- Last day of these posts
- In 2011 , 2012 only
- Today
- New search...