Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

__Config function in Assembly Coding

Status
Not open for further replies.
I'm still a beginner to writing in assembly, but I was just wondering about the __config [hex number] or __config [_CP_OFF & _CPD_OFF & _BOD_OFF] etc. part.

Specifically, why some programs I've seen list each function to turn on or off, and others just a hex number. Basically is there a way to turn my program with __config _CP_OFF & _CPD_OFF & _BOD_OFF etc into a __config 3FFF type one?

Code:
	list      p=16F688           	; list directive to define processor
	#include <p16F688.inc>        	; processor specific variable definitions

	errorlevel  -302              	; suppress message 302 from list file

; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.

	__CONFIG    _CP_OFF & _CPD_OFF & _BOD_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _FCMEN_OFF & _IESO_OFF
 
Yes, each of those 'words' (such as _BOD_OFF) is simply replaced by a number during assembly, these values are listed in the .INC file, you can pick the ones you want and simply AND them together.

Or you can look at the datasheet for the PIC and pickout the binary value for the settings you want, and then convert to HEX.

Or, you can use WinPicProg, which displays the HEX value for the options you select with the tickboxes.
 
That's what I thought, I've looked up the equ codes in the inc file and added them together, but it comes out at 0x230BC, does that sound right? I wasn't sure, because it looks different on the winpicprog tutorials, I didn't want to accidently code protect or lock the pic somehow.

So it's simply __config 0x230BC ?
 
If you use MPLAB you can use the pull down menu to set the configuration bits. Once all are set the config value is shown in the display. You can then enter this value in your program. The pull down menu also sets the bits for your processor. If the number you enter in the program does not match the number set in the pull down menu the complier will let you know.
 
Ok. ANDed them, and it comes out as 30C4, took a while to find the pull down menu thingy, but yeah that comes out as 30C4 too. So thats great. Thanks.
 
I hate it when people post code on here and it has a hex value for the config. I have no idea if the internal oscillator is being used, if the WDT is on etc. In my mind it's as bad as writing bsf 3,0 instead of bsf STATUS,C.

Also, if you use the supplied names then when you switch to a different chip it will work most of the time and if it doesn't the assembler will give you an error.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top