I have been looking at some code by a very clever little chap from Taiwan. He has some clever little routines in his code, but one bit has me puzzled. He used Hex in his CONFIG like this.
__CONFIG H'0FEE'
Can anyone point me to a sensible read where I can decipher this or could someone kindly throw some light onto how it works please.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The same way you can write to a PORT register vs individual bits, you can do the same with the config register.
On the 12F508 its 12 bits wide but only the lower 5 are used.
Refer to 12F508 Data sheet section 7.1
bit 11-5
Unimplemented: Read as ‘0’
bit 4
MCLRE: GP3/MCLR Pin Function Select bit
1 = GP3/MCLR pin function is MCLR
0 = GP3/MCLR pin function is digital input, MCLR internally tied to VDD
bit 3
CP: Code Protection bit
1 = Code protection off
0 = Code protection on
bit 2
WDTE: Watchdog Timer Enable bit
1 = WDT enabled
0 = WDT disabled
So __CONFIG H'0FEE is:
0 = GP3/MCLR pin function is digital input, MCLR internally
1 = Code protection off
1 = WDT enabled
10 = INTRC = internal RC oscillator
Rest of the bits are don't care.
Last edit: Chuck Hellebuyck 2013-10-22
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, thank you so much for your reply. I guess I didn't look into the Data Sheet properly, even so you have explained it much better than I could hae interpreted it from the data sheet.
Thahnks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been looking at some code by a very clever little chap from Taiwan. He has some clever little routines in his code, but one bit has me puzzled. He used Hex in his CONFIG like this.
Can anyone point me to a sensible read where I can decipher this or could someone kindly throw some light onto how it works please.
The same way you can write to a PORT register vs individual bits, you can do the same with the config register.
On the 12F508 its 12 bits wide but only the lower 5 are used.
Refer to 12F508 Data sheet section 7.1
bit 11-5
Unimplemented: Read as ‘0’
bit 4
MCLRE: GP3/MCLR Pin Function Select bit
1 = GP3/MCLR pin function is MCLR
0 = GP3/MCLR pin function is digital input, MCLR internally tied to VDD
bit 3
CP: Code Protection bit
1 = Code protection off
0 = Code protection on
bit 2
WDTE: Watchdog Timer Enable bit
1 = WDT enabled
0 = WDT disabled
bit 1-0
FOSC<1:0>: Oscillator Selection bits
11 = EXTRC = external RC oscillator
10 = INTRC = internal RC oscillator
01 = XT Oscillator
00 = LP Oscillator
So __CONFIG H'0FEE is:
0 = GP3/MCLR pin function is digital input, MCLR internally
1 = Code protection off
1 = WDT enabled
10 = INTRC = internal RC oscillator
Rest of the bits are don't care.
Last edit: Chuck Hellebuyck 2013-10-22
Hi, thank you so much for your reply. I guess I didn't look into the Data Sheet properly, even so you have explained it much better than I could hae interpreted it from the data sheet.
Thahnks