Jump to content

Sample Code For Pic12f629/675 Processors


Recommended Posts

I copied the demo C2C program - Sample code for PIC12F629/675 processors and started a project for a BoostC V6.55, 12F629, 20 LED chaser for xmas.

It crashes on the char definitions

#include <system.h>
char option@0x81;
char trisio@0x85;
char gpio@0x5;
char intcon@0x0B;
char cmcon@0x19;

char led = 1;


void interrupt( void )
{
   if( led )
   {
       gpio = 7;
       led = 0;
   }
   else
   {
       gpio = 0;
       led = 1;
   }

   intcon &= 0xFB;
}

void main()
{
   option = 3;    //set prescaler to 1:16
   trisio = 0;    //set all IOs to output
   //ansel = 0;
   cmcon = 7;    
   gpio = 0;

   intcon = 0xA0;    //enable GIE & TMR0 interrupt

   while( 1 ); //endless loop
}

If option is commented out it will not compile.

If trisio is NOT commented out it will crash, same with gpio, intcon & cmdcon.

This is my first 12series in C and my asm was in 1998. What am I missing?

The example is for C2C so is BoostC doing something I don't see?

Link to post
Share on other sites
...It crashes on the char definitions...

 

I tried to reproduce this problem but didn't see any crash. Just a compile error (expected one). What is your definition of the phrase "compiler crashed"?

 

Regards,

Pavel

Link to post
Share on other sites
...It crashes on the char definitions...

 

I tried to reproduce this problem but didn't see any crash. Just a compile error (expected one). What is your definition of the phrase "compiler crashed"?

 

Regards,

Pavel

OK. So I am a bit blunt. doesn't work = crash. :lol: What error did you expect in example code? C2C compatibility?

 

I see several messages : error: variable "trisio" already exists, same for cmcon, intcon & gpio.

I saw fewer messages today until I noticed that I was compiling for 16F84A :)

I have no trouble running complementary LED drive on the EZ controller but I have some 12F629 on the way so I was trying to learn something new (old).

Thanks ;)

Link to post
Share on other sites

rfhale,

OK. So I am a bit blunt. doesn't work = crash. ;)
FYI (as I know that you are not actually a programmer): when you use the term crash as far as a programs concerned it means things ended in quite an unexpected state (like locked out) or thing have gone uncontrolled or totally bonkers :)

 

Regards

Dave

Link to post
Share on other sites
...I see several messages : error: variable "trisio" already exists, same for cmcon, intcon & gpio...

 

I see the same errors. Once the offending vars are removed code compiles with no prob:

 

#include <system.h>

char led = 1;


void interrupt( void )
{
  if( led )
  {
      gpio = 7;
      led = 0;
  }
  else
  {
      gpio = 0;
      led = 1;
  }

  intcon &= 0xFB;
}

void main()
{
  option_reg = 3;    //set prescaler to 1:16
  trisio = 0;    //set all IOs to output
  //ansel = 0;
  cmcon = 7;    
  gpio = 0;

  intcon = 0xA0;    //enable GIE & TMR0 interrupt

  while( 1 ); //endless loop
}

 

Regards,

Pavel

Link to post
Share on other sites
...I see several messages : error: variable "trisio" already exists, same for cmcon, intcon & gpio...

 

I see the same errors. Once the offending vars are removed code compiles with no prob:

Regards,

Pavel

Back to the original post:

I am using SourceBoost V6.55, 12F629, BoostC.

 

If I comment out all the char "register", as you did, it will not compile. I get an error when I comment out: char option...

This was my original question. Why is option different from trisio, etc?

Apparently it is not, where you live.

When I created my project I changed the target to 12F629. That is all I changed, did I miss something?

I can compile if I declare char option@0x81; and I can live with that, but I wonder why?

Link to post
Share on other sites
I see the same errors. Once the offending vars are removed code compiles with no prob:

Regards,

Pavel

I finally noticed that option quietly changed from the example to option_reg in Pavel's post. That seems like a large change to me since the error disppeared when I tried it. Option, as in the original example was a regular variable, not a SFR.

I'll email a functioning 12F629 example for your page. It flashes 20 LEDs and requires the child to push a button after a time so the batteries won't run down.

I wish my brain was more pliable so that learning wouldn't hurt so much. ;)

Link to post
Share on other sites
Some kind of Victorian work practise employing small children to push buttons because a gentleman would never perform such a working class task.

Or have I misunderstood?

Yes I think you are right - Regarded as a definate treat by children if they survived chimney sweeping.

 

Regards

Dave

Link to post
Share on other sites
Some kind of Victorian work practise employing small children to push buttons because a gentleman would never perform such a working class task.

Or have I misunderstood?

Yes I think you are right - Regarded as a definate treat by children if they survived chimney sweeping.

 

Regards

Dave

I prefer to think we are more Edwardian, running around naked and carefree. It's -36C here and you want ME to get out of bed to push a button? ;)

Link to post
Share on other sites
Some kind of Victorian work practise employing small children to push buttons because a gentleman would never perform such a working class task.

Or have I misunderstood?

Yes I think you are right - Regarded as a definate treat by children if they survived chimney sweeping.

 

Regards

Dave

I prefer to think we are more Edwardian, running around naked and carefree. It's -36C here and you want ME to get out of bed to push a button? :lol:

At least it proves you are alive :D

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...