You are on page 1of 1

Process for Defining PIC Configuration Bits in Code

(so you dont need to set them every time you download edited code to your PIC)

1) Navigate to the C:\MPASM directory and open the .INC file for your PIC in Notepad 2) At the very bottom of the file is a section entitled "Configuration Bits" defining the possible values for the bits for different settings as well as instructions and sample code for setting them in your program. 3) for example, the PIC16F88 has two config registers. To set register 1 (which contains all the important config bits) copy the entire line which looks like: ; __CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_ON & _INTRC_IO 4) Paste this line at the very top of your program (above DEFINE OSC 8 for the pic16f88). Replace the preceding semicolon with an @ symbol like so (which lets the picbasic pro compiler know this is an assembly language statement): @ __CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_ON & _INTRC_IO 5) Change the particular bits that you need with the values obtained from the list at the end of the INC file. (the config line above has all the proper settings for our purposes for the PIC16F88. It should match with the guidelines that are in the current code template on the mech307 site) 6) When you save your program and compile it, you will likely see an error, "Overwriting previous address contents" but the build will succeed as long as there are no other problems with your program. You can ignore this error, because you are indeed overwriting the default values with the settings you want.

You might also like