Jump to content
Benj

12f675 Working With C2c But Not Boostc

Recommended Posts

Hello

 

I have two simple programs for the 12F675. They are both using the internal MCLR and using the pin as an input.

 

Here is the code in C2C:

 

void main()
{
   //PIC Initialisation
   ansel = 0x20;
   cmcon = 0x07;
   //Interrupt initialisation code
   option_reg = 0xC0;
   while( 1 )
   {
   trisio = trisio | 0x08;
   FCV_TEMP = (gpio & 0x08 == 0x08);

   if( FCV_TEMP )
   {
       trisio = 0x00;
       gpio = 3;
   }
   else
   {
       trisio = 0x00;
       gpio = 0;
   }
   }
   mainendloop: goto mainendloop;
}

 

Here is the same code implemented in BoostC:

 

void main()
{
   //Initialisation
   ansel = 0x20;
       cmcon = 0x07;
   //Interrupt initialisation code
   option_reg = 0xC0;
   //Loop: While 1
   while( 1 )
   {
       //Input: A3 -> temp
       trisio = trisio | 0x08;
       FCV_TEMP = (gpio & 0x08 == 0x08);

       //Decision: temp?
       if( FCV_TEMP )
       {
           //Output: 0x03 -> PORT A
           trisio = 0x00;
           gpio = 0X03;
       } 
               else 
               {
           //Output: 0 -> PORT A
           trisio = 0x00;
           gpio = 0;
       }
   }
   mainendloop: goto mainendloop;
}

 

The code compiled with C2C works perfectly.

The code compiled with BoostC will not run.

 

Both have exactly the same configuration settings.

Please can anyone help with this problem as the code must work using the BoostC.

Edited by Benj

Share this post


Link to post
Share on other sites

What are your device configuration settings (or pragma) for the boostC version?

Share this post


Link to post
Share on other sites
What are your device configuration settings (or pragma) for the boostC version?

 

The device configuration settings are the following.

 

Oscillator HS

Watchdog Off

Power Up Timer Off

Master Clear Enable Internal

Brown Out Off

Code Protect Off

Data EE Read Protect Off

Bandgap Calibration Lowest

Share this post


Link to post
Share on other sites

Benj,

Hello

 

I have two simple programs for the 12F675. They are both using the internal MCLR and using the pin as an input.

....

....

The code compiled with C2C works perfectly.

The code compiled with BoostC will not run.

 

Both have exactly the same configuration settings.

Please can anyone help with this problem as the code must work using the BoostC.

It looks like C2C compiler does apply operator precedence correctly, so gpio & 0x08 gets evaluated first and then the == 0x08 second.

 

BoostC has the correct precedence on these operators, so to fix the code change:

FCV_TEMP = (gpio & 0x08 == 0x08);

to

FCV_TEMP = ((gpio & 0x08) == 0x08);

.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Thanks Dave

 

That has given some progress but I am still having problems programming the PIC micro with the hex code that was generated.

 

Here is the Hex file that the compiler spits out

:020000003428A2
:0A000600203083169F00073083129C
:100010009900C030831681000830831605048500DE
:10002000083083120505A200A1010830220203193D
:10003000A10AA10803192828FC30831605058500AC
:10004000FC3083120505A2000130220485000C2833
:10005000FC30831605058500FC3083120505A200DF
:100060000230220485000C2883122010A0108A116F
:040070000A12032845
:02400E00970F0A
:00000001FF

 

But the program only seems to get sent to the PICmicro correctly if i remove the top two lines of hex code.

:100010009900C030831681000830831605048500DE
:10002000083083120505A200A1010830220203193D
:10003000A10AA10803192828FC30831605058500AC
:10004000FC3083120505A2000130220485000C2833
:10005000FC30831605058500FC3083120505A200DF
:100060000230220485000C2883122010A0108A116F
:040070000A12032845
:02400E00970F0A
:00000001FF

 

With the two lines removed the MCLR input works perfectly.

Any idea what the two lines do and why they would stop the PIC from being programmed correctly?

Share this post


Link to post
Share on other sites
Thanks Dave

 

That has given some progress but I am still having problems programming the PIC micro with the hex code that was generated.

...

With the two lines removed the MCLR input works perfectly.

Any idea what the two lines do and why they would stop the PIC from being programmed correctly?

Have a look here http://en.wikipedia.org/wiki/Intel_HEX regard intel hex file format.

 

You will find that those lines are part of the prgram.

By decoding the address you can find what part of asm code it is (startup and reset vectors probably).

 

Program:
:02 0000 00 3428A2
:0A 0006 00 203083169F00073083129C
:10 0010 00 9900C030831681000830831605048500DE
:10 0020 00 083083120505A200A1010830220203193D
:10 0030 00 A10AA10803192828FC30831605058500AC
:10 0040 00 FC3083120505A2000130220485000C2833
:10 0050 00 FC30831605058500FC3083120505A200DF
:10 0060 00 0230220485000C2883122010A0108A116F
:04 0070 00 0A12032845

Config:
:02 400E 00 970F0A

End records
:00 0000 01 FF

 

Regards

Dave

Share this post


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...