CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

using #hexcomment to embed BORXX into .hex file

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cadience



Joined: 06 Jun 2007
Posts: 1

View user's profile Send private message

using #hexcomment to embed BORXX into .hex file
PostPosted: Wed Jun 06, 2007 5:21 pm     Reply with quote

Hello ALL

PIC = 18F722
Compiler = 4.0.20

I have several different builds of devices with different fuse settings and wish to include the BOR settings into the hex file to allow for easy identification via opening the .hex in an editor. Is this possible?

I attempted to do this, along with other fuses to allow toggling of pertinent compile-time options from the command line. I also allow the "master node" to inspect the devices to see what is enabled/disabled for easy display/debugging over a web page.


Code:

#include <18F8722.h>

//#define CCA_DISABLE_WDT    //when defined, disables the WDT
#define CCA_SERIAL_DEBUG   //when defined, the hardware monitor is enabled
//#define CCA_BROWNOUT_DISABLED  //when defined, turn off brownout protection

#fuses HS        //use a clock >4Mhz frequency
#fuses MCLR      //allow Master Clear (MCLR) pin to reset the MCU
#fuses NOLVP     //set NO Low Voltage Programming as ICD does not support it.
#fuses BROWNOUT  //allow brownout protection (reset)
#fuses BORV42    //do a brownout reset if Vdd drops below 4.2 volts

//enable the Watch Dog Timer fuse - if defined
#ifdef CCA_DISABLE_WDT
#fuses NOWDT       
#else
#fuses WDT128
#endif

unisnged int cca_brownoutVal; //divide by 10 to get actual voltage
//....
// other compile switches and code
// ...

   //set up the watch dog timer
#ifdef CCA_DISABLE_WDT
    #hexcomment PIC: WDT DISABLED
    setup_wdt(WDT_OFF);
    cca_wdtEnabled = FALSE;
#else
    #hexcomment PIC: WDT ENABLED
    setup_wdt(WDT_ON);
    cca_wdtEnabled = TRUE;
#endif



  //determine BROWNOUT settings - this is where my problem is
   #if getenv("FUSE_SET:BROWNOUT")
      #hexcomment PIC: BROWNOUT ENABLED (V must be next or BOR is invalid)
         //set to an invalid value - will be reset if valid
      cca_brownoutVal = 50;
      #if getenv("FUSE_SET:BOR45"))     
        cca_brownoutVal = 45;
        #hexcomment PIC: BROWNOUT = 4.5V
      #endif
     
      #if getenv("FUSE_SET:BOR42"))     
        cca_brownoutVal = 42;
        #hexcomment PIC: BROWNOUT = 4.2V
      #endif
     
      #if getenv("FUSE_SET:BOR27"))     
        cca_brownoutVal = 27;
        #hexcomment PIC: BROWNOUT = 27V
      #endif
     
      #if getenv("FUSE_SET:BOR22"))     
        cca_brownoutVal = 22;
      #hexcomment PIC: BROWNOUT = 2.2V
      #endif
       
    #else
        #hexcomment PIC: BROWNOUT DISABLED
        //set to 0 - disabled
        cca_brownoutVal = 00;
    #endif



here's the snippet of the hexfile generated
Quote:

; PIC: compile date = "06-Jun-07" time = "18:43:59"
; PIC: ICD DISABLED
; PIC: HARDWARE_MONITOR ENABLED
; PIC: CAN NODE ID SET NORMALLY
; PIC: TASK PROFILING DISABLED
; PIC: FANS ENABLED
; PIC: WDT ENABLED
; PIC: BROWNOUT ENABLED (V must be next or BOR is invalid)
; PIC: $RCSfile$ $Revision$ $Date$
; PIC: $RCSfile$ $Revision$ $Date$
;
; etc


As you can see, the getenv("FUSE_SET:BOR42") does not show any signs of being set.
As I'm trying to embed the info into the .hex file, I can't inspect the register at runtime. Any suggestions?

Also, it doesn't appear that the CCS compile supports #elseif or #elsif, is this true?
_________________
-John Williams
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Jun 06, 2007 5:50 pm     Reply with quote

Quote:
Also, it doesn't appear that the CCS compile supports #elseif or #elsif, is this true?
From the manual: #elif
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group