# Learning to program the PIC16LF1823

#### cmartinez

Joined Jan 17, 2007
7,881
I'm completely unfamiliar with any of Microchip's products, but now it has become imperative that I work on a small project involving the PIC10LF322. As a reference, I consider myself quite proficient with the 8051 architecture, but the PIC architecture is alien to me. So I'd very much appreciate it if any of you had the patience of helping me walk through my first baby steps.

I've already bought a few of said chips, and bought a PICkit 3 programmer for this application. My most important requirement is that I learn how to program this chip using assembly language, and not C.

Specifically, I'd like to be pointed to:
- Where can I download an assembly compiler for this chip? I've already downloaded the MPLAB X IDE software from MicroChip, and I haven't been able to find anything related to assembly language in it.
- Where can I download a few samples in assembly for this chip? I need to learn and study its syntax and general rules, so some sort of manual or even book that I could buy or download would be appreciated.

Of course, I've already studied the datasheet, and have begun to understand some of the concepts involving its different registers and interrupts. But I have no clue as to how and where to start programming and compiling assembly, and then loading the program into the chip.

#### Raymond Genovese

Joined Mar 5, 2016
1,653
I'm completely unfamiliar with any of Microchip's products, but now it has become imperative that I work on a small project involving the PIC10LF322. As a reference, I consider myself quite proficient with the 8051 architecture, but the PIC architecture is alien to me. So I'd very much appreciate it if any of you had the patience of helping me walk through my first baby steps.

I've already bought a few of said chips, and bought a PICkit 3 programmer for this application. My most important requirement is that I learn how to program this chip using assembly language, and not C.

Specifically, I'd like to be pointed to:
- Where can I download an assembly compiler for this chip? I've already downloaded the MPLAB X IDE software from MicroChip, and I haven't been able to find anything related to assembly language in it.
- Where can I download a few samples in assembly for this chip? I need to learn and study its syntax and general rules, so some sort of manual or even book that I could buy or download would be appreciated.

Of course, I've already studied the datasheet, and have begun to understand some of the concepts involving its different registers and interrupts. But I have no clue as to how and where to start programming and compiling assembly, and then loading the program into the chip.
MPASM will go right into MPLAB X IDE (I actually thought it gets downloaded with the IDE). I'm sure you can find it, but when you create a project you will be asked what you want to use debugger/compiler and so on - see if it is there.

I would suggest the Gooligum tutorials https://www.gooligum.com.au/PIC-Tutorials
A few of these are free and likely to be a couple that you will appreciate as they are (still) a good get-your-feet-wet by doing something.

#### cmartinez

Joined Jan 17, 2007
7,881
MPASM will go right into MPLAB X IDE (I actually thought it gets downloaded with the IDE). I'm sure you can find it, but when you create a project you will be asked what you want to use debugger/compiler and so on - see if it is there.

I would suggest the Gooligum tutorials https://www.gooligum.com.au/PIC-Tutorials
A few of these are free and likely to be a couple that you will appreciate as they are (still) a good get-your-feet-wet by doing something.
Thanks Ray! ... as a matter of fact, I found that the MPASM was installed along with the MPLAB software a few moments before I saw your post. Right now I'm studing the examples included in the software. But I'm not sure I like the MPLAB's user interface, I find it a bit overbearing and confusing ... same thing happened to me when I tried to learn how to use Atmel's software ... in the end, I used a text editor of my choice (programmer's notepad 2, which is an extremely friendly and simple to use editor) and ran the compiler from the command line.

Thanks for linking me to the PIC tutorials, I'll have a look at them and let you know how it went.

#### Raymond Genovese

Joined Mar 5, 2016
1,653
Thanks Ray! ... as a matter of fact, I found that the MPASM was installed along with the MPLAB software a few moments before I saw your post. Right now I'm studing the examples included in the software. But I'm not sure I like the MPLAB's user interface, I find it a bit overbearing and confusing ... same thing happened to me when I tried to learn how to use Atmel's software ... in the end, I used a text editor of my choice (programmer's notepad 2, which is an extremely friendly and simple to use editor) and ran the compiler from the command line.

Thanks for linking me to the PIC tutorials, I'll have a look at them and let you know how it went.
I both love it and hate it. But, as usual, you use it and get used to it and it works, pretty much, anyways. Then, you switch to something else and have to get used to it and switch back and so on and so forth. I felt the same way about Eclipse, and then got used to it. I can even get used to Visual Studio stuff. Still, there is pain in spending more time in figuring out how to use the program instead of using the program to write programs. I think the end result is that I get a little neophobic - I was starting to get into some PSoC Creator and after a while I just said...enough...Atmel Studio has been sitting on my desktop for a year and I have only flashed an LED. For all of its limitations, Arduino IDE took all of about 10 minutes to learn (or so it seems).

#### jpanhalt

Joined Jan 18, 2008
11,087
I'm completely unfamiliar with any of Microchip's products, but now it has become imperative that I work on a small project involving the PIC10LF322. As a reference, I consider myself quite proficient with the 8051 architecture, but the PIC architecture is alien to me. So I'd very much appreciate it if any of you had the patience of helping me walk through my first baby steps.

I've already bought a few of said chips, and bought a PICkit 3 programmer for this application. My most important requirement is that I learn how to program this chip using assembly language, and not C.

Specifically, I'd like to be pointed to:
- Where can I download an assembly compiler for this chip? I've already downloaded the MPLAB X IDE software from MicroChip, and I haven't been able to find anything related to assembly language in it.
I use MPLab 8.92. It is still available for download, but does not support the very newest chips. I did try on an early version of MPLabX and found it unusable for Assembly. I understand from @Ian Rogers and others that those earlier problems have been somewhat resolved, but I have not ventured out into that realm again.
- Where can I download a few samples in assembly for this chip? I need to learn and study its syntax and general rules, so some sort of manual or even book that I could buy or download would be appreciated.
Can you be more specific? The instruction set for that chip is very similar to the other mid-range chips. It has a single FSR. If you can stand an 8-pin version in a small footprint, the enhanced mid-range chips (e.g., 12F1840) are superior. If you just want an extended example of the instruction set, I will attach a link. There is only one operand and a destination ('d')(i.e., F = a file, or W = working register). STATUS lets you keep track of carry (STATUS,0), zero (STATUS,2), and nibble carry (STATUS,1). It can be involved in bank select. EDIT: Chip has only one bank. Rest is General Purpose Registers (RAM). I would have to review that chip again to know that (never actually used that chip).
Of course, I've already studied the datasheet, and have begun to understand some of the concepts involving its different registers and interrupts. But I have no clue as to how and where to start programming and compiling assembly, and then loading the program into the chip.
What sort of thing would you like? I have some stuff for the 12F683 that is very similar. One advantage of the enhanced mid-range, besides having 2 FSR's, is automatic context saving and restoration. Doesn't save a lot of processor time, but it does save having to type it.

John

Edit#2: MMcLaren has done a bit with that chip. Here is one example: http://picforum.ric323.com/viewtopic.php?t=8&p=21#p1112 As I recall, he has also done a backpack driver for an LCD despite having only 6 pins to use (See: Edit #3).
Edit#3: Memory failed. It was a 12F6xx for the LCD driver directly or 2 pins from an MCU plus a counter (e.g., 74HC164). Unfortunately, the code for the latter was for an 18F PIC, not the 10F.

Last edited:

#### AlbertHall

Joined Jun 4, 2014
12,190
I both love it and hate it. But, as usual, you use it and get used to it and it works, pretty much, anyways. Then, you switch to something else and have to get used to it and switch back and so on and so forth. I felt the same way about Eclipse, and then got used to it. I can even get used to Visual Studio stuff. Still, there is pain in spending more time in figuring out how to use the program instead of using the program to write programs. I think the end result is that I get a little neophobic - I was starting to get into some PSoC Creator and after a while I just said...enough...Atmel Studio has been sitting on my desktop for a year and I have only flashed an LED. For all of its limitations, Arduino IDE took all of about 10 minutes to learn (or so it seems).
The arduino IDE is easy because it doesn't do much.
MPLABX includes a simulator which allows you to single step through your program (C or assembler), view or change RAM or SFRs, and you can set up a file to simulate external hardware. You don't need the actual hardware to do some quite detailed debugging. Natuarlly all this takes some learning.

#### Dodgydave

Joined Jun 22, 2012
10,591
I'm completely unfamiliar with any of Microchip's products, but now it has become imperative that I work on a small project involving the PIC10LF322. As a reference, I consider myself quite proficient with the 8051 architecture, but the PIC architecture is alien to me. So I'd very much appreciate it if any of you had the patience of helping me walk through my first baby steps.

I've already bought a few of said chips, and bought a PICkit 3 programmer for this application. My most important requirement is that I learn how to program this chip using assembly language, and not C.

Specifically, I'd like to be pointed to:
- Where can I download an assembly compiler for this chip? I've already downloaded the MPLAB X IDE software from MicroChip, and I haven't been able to find anything related to assembly language in it.
- Where can I download a few samples in assembly for this chip? I need to learn and study its syntax and general rules, so some sort of manual or even book that I could buy or download would be appreciated.

Of course, I've already studied the datasheet, and have begun to understand some of the concepts involving its different registers and interrupts. But I have no clue as to how and where to start programming and compiling assembly, and then loading the program into the chip.
I would start with the 12F675 or 609 pics, these are in the library samples in Mplab, it will give you an idea of how to set up ports for I/O and the main registers like Status, Gpio, Intosc, start by flashing a led on a port, and button pressing, then you can move onto your pic, here is a page for the 12f675 .

https://www.microchip.com/forums/m/tm.aspx?m=54901&p=1

Last edited:

Joined Jul 18, 2013
26,291
Specifically, I'd like to be pointed to:
- Where can I download an assembly compiler for this chip? I've already downloaded the MPLAB X IDE software from MicroChip, and I haven't been able to find anything related to assembly language in it.
- Where can I download a few samples in assembly for this chip? I need to learn and study its syntax and general rules, so some sort of manual or even book that I could buy or download would be appreciated.
.
Also look at the free Gooligum tutorials, they start off with the 12F pin series in assembly, C later on.
Edit: I see Gooligum already mentioned!
I agree the 12F675 or for a few extras, the 12F1822/23 etc.
Also I much prefer the MPLAB IDE for assembley rather than the X ver.
The IDE has a simulator also.
Max.

Last edited:

Joined Jul 18, 2013
26,291
BTW there is a 12F development board in ebay for \$5.00.
Comes with a 12F675.
Includes ICP connector.
311674167468
Max.

Last edited:

#### cmartinez

Joined Jan 17, 2007
7,881
Thank you all for your responses. I've already found a few samples specific of the 10LF322 and I'm currently studying them. My learning has been exponential thanks to my previous experience with the 8051.

Anyway, I'm going to:
1.- Turn a LED on and off using an output pin while pressing a pushbutton connected to an input pin (configured with a weak pull-up).
2.- Flash said LED using a delay loop.
3.- Flash the LED using a timer interrupt.
4.- Flash the LED a number of times using a timer interrupt activated by an external interrupt.

And then I'll decide what's next. I'll be posting my code (or snippets of it) in this thread to record my progress.

Thanks again to all.

Joined Jul 18, 2013
26,291
The code in the Gooligum tutorials should transfer over easily , just watch the bankswitching and any difference in the particular registers used.
Otherwise should be very compatible.
Max.

#### cmartinez

Joined Jan 17, 2007
7,881
The code in the Gooligum tutorials should transfer over easily , just watch the bankswitching and any difference in the particular registers used.
Otherwise should be very compatible.
Max.
I doubt there will be any bank switching involved in my project. The 10LF322 has only one register bank, from what I gather. But it's good to know to watch out for that feature in other PICs if in the future I decide to use a more advanced model.

#### MMcLaren

Joined Feb 14, 2010
858
I've only done a couple simple programs for 10F322. If it helps... here's one that displays the Arecibo message in Morse code on an LED at approximately 12-wpm. It demonstrates how to read a table of 14-bit 'words' from program memory.

Good luck in your studies. Have fun.

Cheerful regards, Mike

Code:
;******************************************************************
;                                                                 *
;   Filename: 10F320 Arecibo.asm                                  *
;     Author: Mike McLaren, K8LH                                  *
;       Date: 19-Sep-2014                                         *
;                                                                 *
;   Send Arecibo message as continuous ~12-WPM stream of Morse    *
;   code on the active lo LED connected between RA2 and VDD.      *
;                                                                 *
;      MPLab: 8.92    (tabs = 8)                                  *
;      MPAsm: 5.51                                                *
;                                                                 *
;******************************************************************

list p=10f322, st=off
#include "p10f322.inc"

__CONFIG _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _LVP_OFF

;--< variables >---------------------------------------------------

cblock 0x40             ; 10F320 RAM (0x40..0x7F)

endc

;--< constants >---------------------------------------------------

#define led PORTA,2             ; LED on RA2
#define timer NCO1INCL          ; use a register instead of RAM
#define bitctr NCO1INCH         ;  "

;******************************************************************
;  reset vector                                                   *
;******************************************************************
org 0x000
v_reset

;******************************************************************
;  main init                                                      *
;******************************************************************

init
clrf    OSCCON          ; INTOSC = ~31-kHz, Tcy ~129-us   |B0
;
;  setup PORTA
;
clrf    TRISA           ; RA3 input, RA2-RA0 outputs      |B0
clrf    ANSELA          ; analog off for digital I/O      |B0
bsf     led             ; turn active lo LED off          |B0

;******************************************************************
;  main loop                                                      *
;******************************************************************

loop
movlw   low(arecibo)    ; prep memory address pointers    |B0
bcf     PMCON1,CFGS     ; prep to read program memory     |B0
call    wait2           ; message repeat delay            |B0
call    wait2           ;  "                              |B0
call    wait2           ;  "                              |B0
nxtbyte
movlw   13              ;                                 |B0
movwf   bitctr          ; bitctr = 13                     |B0
bsf     PMCON1,RD       ; read 14-bit data from flash     |B0
nop                     ; required nop                    |B0
nop                     ; required nop                    |B0
nxtbit
bcf     PORTA,2         ; turn active lo LED 'on'         |B0
btfsc   PMDATH,5        ; b13 = '0'? yes, skip, else      |B0
call    wait2           ; do ~99-ms * 3 for a '1' bit     |B0
call    wait1           ; do ~99-ms * 1 for a '0' bit     |B0
bsf     PORTA,2         ; turn active lo LED 'off'        |B0
call    wait1           ; do ~99-ms inter-bit space       |B0
rlf     PMDATL,F        ; shift 14-bit data left to get   |B0
rlf     PMDATH,F        ; next bit into b13 position      |B0
decfsz  bitctr,F        ; last bit? yes, skip, else       |B0
goto    nxtbit          ; branch (send another bit)       |B0
incfsz  PMADRL,F        ; last byte? yes, skip, else      |B0
goto    nxtbyte         ; branch (send next byte)         |B0
goto    loop            ; branch (done, start over)       |B0

wait2
call    wait1           ;                                 |B0
wait1
decfsz  timer,F         ; ~99-msecs                       |B0
goto    wait1           ;                                 |B0
return                  ;                                 |B0

;******************************************************************
;
;  1679 bits (very last bit in the table isn't used) organized
;  and displayed as 73 rows and 23 columns.  First and most sig-
;  nificant bit in table is the top left of image.
;
org 0x088
arecibo
dw b'00000010101010', b'00000000000101', b'00000101000000'
dw b'01001000100010', b'00100101100101', b'01010101010101'
dw b'00100100000000', b'00000000000000', b'00000000000000'
dw b'01100000000000', b'00000000110100', b'00000000000000'
dw b'00011010000000', b'00000000000101', b'01000000000000'
dw b'00000011111000', b'00000000000000', b'00000000000000'
dw b'01100001110001', b'10000110001000', b'00000000001100'
dw b'10000110100011', b'00011000011010', b'11111011111011'
dw b'11101111100000', b'00000000000000', b'00000001000000'
dw b'00000000000100', b'00000000000000', b'00000000000010'
dw b'00000000000000', b'00111111000000', b'00000001111100'
dw b'00000000000000', b'00000001100001', b'10000111000110'
dw b'00100000001000', b'00000010000110', b'10000110001110'
dw b'01101011111011', b'11101111101111', b'10000000000000'
dw b'00000000000001', b'00000011000000', b'00010000000000'
dw b'01100000000000', b'00001000001100', b'00000000111111'
dw b'00000110000001', b'11110000000000', b'11000000000000'
dw b'01000000001000', b'00000100000100', b'00001100000001'
dw b'00000001100001', b'10000001000000', b'00001100010000'
dw b'11000000000000', b'00011001100000', b'00000000110001'
dw b'00001100000000', b'01100001100000', b'01000000010000'
dw b'00100000000100', b'00010000000110', b'00000001000100'
dw b'00000011000000', b'00100010000000', b'00100000001000'
dw b'00100000001000', b'00001000000010', b'00000000000110'
dw b'00000000110000', b'00001100000000', b'01000111010110'
dw b'00000000001000', b'00001000000000', b'00000100000111'
dw b'11000000000000', b'10000101110100', b'10110110000001'
dw b'00111001001111', b'11101110000111', b'00000110111000'
dw b'00000010100000', b'11101100100000', b'01010000011111'
dw b'10010000001010', b'00001100000010', b'00001101100000'
dw b'00000000000000', b'00000000000000', b'00111000001000'
dw b'00000000000111', b'01010001010101', b'01010011100000'
dw b'00001010101000', b'00000000000001', b'01000000000000'
dw b'00111110000000', b'00000000011111', b'11110000000000'
dw b'00111000000011', b'10000000001100', b'00000000011000'
dw b'00001101000000', b'00010110000011', b'00110000000110'
dw b'01100001000101', b'00000101000100', b'00100010010001'
dw b'00100010000000', b'01000101000100', b'00000000001000'
dw b'01000010000000', b'00000100000000', b'01000000000000'
dw b'00100101000000', b'00000111100111', b'11010011110000'

;******************************************************************
end

Last edited:

#### cmartinez

Joined Jan 17, 2007
7,881
Ok, here's the code for a "blinkie" very generoulsy posted by @OBW0549 in another thread:

Code:
;**********************************************************************
;                                                                     *
;   Basic 10F322 "blinky"-- blinks LED on Port A bit 2                *
;   Derived from 10F222TMPO.ASM                                       *
;                                                                     *
;**********************************************************************
list      p=10F322            ; list directive to define processor
#include <p10F322.inc>        ; processor specific variable definitions
;    Configure chip via IDE menu and ignore the following line:
;   __CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ
;***** RAM VARIABLES
TEMP_VAR    UDATA
temp1       RES     1
;***** CODE
MAIN    CODE    0x000
movlw   0x0F
movwf   LATA            ; preset all outputs to 0
movlw   0x00            ; set all bits as outputs
movwf   TRISA
;    movlw   0x0F            ; enable weak pullups on all inputs
;    movwf   WPUA
;    bcf     OPTION_REG, NOT_WPUEN   ; WPU master enable
clrf    temp1

movlw   0x10
movwf   OSCCON
nop
mainloop
bsf     LATA, LATA2        ; turn the LED on
movlw   .250            ; set up 1/4 second delay
movwf   temp1

delayloop1
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
decfsz  temp1
goto    delayloop1

bcf     LATA, LATA2        ; turn the LED off
movlw   .250            ; set up 1/4 second delay
movwf   temp1

delayloop2
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
decfsz  temp1
goto    delayloop2

nop
goto    mainloop
END                       ; directive 'end of program'
First, I'm trying to understand what the _CONFIG line is all about. Where can I find a list of the constants involved and their proper use?

#### jpanhalt

Joined Jan 18, 2008
11,087
The Configuration sets various MCU operating conditions, such as oscillator type, whether MCLR is enabled for reset (setting doesn't affection programming), watch dog timer ( a timer to reset if the program hangs) and so forth. It is best described by checking the datasheet and begin at page 19. It can be one word or several. Each bit is set to set one of the conditions. In the IDE, you can find settings when setting it up to program.

Here is what the configure window looks like in MPLAB 8.92:

You can click on the drop-down menus to change things. I have found just using the datasheet is easier, unless I am in the middle of something and just want to change something (like oscillator type) and can't remember the proper abbreviation.

#### Raymond Genovese

Joined Mar 5, 2016
1,653
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ

There are options that can be programmed - see section 3.1, p20 of the data sheet. BTW, I only have experience with the 202-204 PIC10 series - this one looks better and I have to put it in my 'save for later' list.

#### cmartinez

Joined Jan 17, 2007
7,881
The Configuration sets various MCU operating conditions, such as oscillator type, whether MCLR is enabled for reset (setting doesn't affection programming), watch dog timer ( a timer to reset if the program hangs) and so forth. It is best described by checking the datasheet and begin at page 19. It can be one word or several. Each bit is set to set one of the conditions. In the IDE, you can find settings when setting it up to program.
Thanks John ... I've located the Configuration Word description in the datasheet, and the function of each of its bits. What has me confused is that I'm thinking about the Configuration Word as a register, and that it might be accessed through move instructions, or by simply reading and writing its bits individually, but I'm seeing that maybe that's not the case.

Joined Jul 18, 2013
26,291
See page 20 of the manual also the .INC file.

[code
Code:
;==========================================================================
;
;  RAM Definitions
;
;==========================================================================
__MAXRAM  H'007F'

;==========================================================================
;
;  Configuration Bits
;
;  CONFIG  2007h
;
;==========================================================================

; The following is an assignment of address values for all of the
; configuration registers for the purpose of table reads
_CONFIG  EQU  H'2007'

;----- CONFIG Options --------------------------------------------------
_FOSC_INTOSC  EQU  H'3FFE'  ; INTOSC oscillator: CLKIN function disabled
_FOSC_EC  EQU  H'3FFF'  ; EC: CLKIN function enabled

_BOREN_OFF  EQU  H'3FF9'  ; Brown-out Reset disabled
_BOREN_SBODEN  EQU  H'3FFB'  ; Brown-out Reset controlled by the SBOREN bit in the BORCON register
_BOREN_NSLEEP  EQU  H'3FFD'  ; Brown-out Reset enabled while running and disabled in Sleep
_BOREN_ON  EQU  H'3FFF'  ; Brown-out Reset enabled

_WDTE_OFF  EQU  H'3FE7'  ; WDT disabled
_WDTE_SWDTEN  EQU  H'3FEF'  ; WDT controlled by the SWDTEN bit in the WDTCON register
_WDTE_NSLEEP  EQU  H'3FF7'  ; WDT enabled while running and disabled in Sleep
_WDTE_ON  EQU  H'3FFF'  ; WDT enabled

_PWRTE_ON  EQU  H'3FDF'  ; PWRT enabled
_PWRTE_OFF  EQU  H'3FFF'  ; PWRT disabled

_MCLRE_OFF  EQU  H'3FBF'  ; MCLR pin function is digital input, MCLR internally tied to VDD
_MCLRE_ON  EQU  H'3FFF'  ; MCLR pin function is MCLR

_CP_ON  EQU  H'3F7F'  ; Program memory code protection is enabled
_CP_OFF  EQU  H'3FFF'  ; Program memory code protection is disabled

_LVP_OFF  EQU  H'3EFF'  ; High-voltage on MCLR/VPP must be used for programming
_LVP_ON  EQU  H'3FFF'  ; Low-voltage programming enabled

_LPBOR_OFF  EQU  H'3DFF'  ; BOR disabled
_LPBOR_ON  EQU  H'3FFF'  ; BOR enabled

_BORV_HI  EQU  H'3BFF'  ; Brown-out Reset Voltage (Vbor), high trip point selected.
_BORV_27  EQU  H'3BFF'  ; Brown-out Reset Voltage (Vbor), high trip point selected.
_BORV_LO  EQU  H'3FFF'  ; Brown-out Reset Voltage (Vbor), low trip point selected.
_BORV_24  EQU  H'3FFF'  ; Brown-out Reset Voltage (Vbor), low trip point selected.

_WRT_ALL  EQU  H'27FF'  ; 000h to 1FFh write protected, no addresses may be modified by PMCON control
_WRT_HALF  EQU  H'2FFF'  ; 000h to 0FFh write protected, 100h to 1FFh may be modified by PMCON control
_WRT_BOOT  EQU  H'37FF'  ; 000h to 07Fh write protected, 080h to 1FFh may be modified by PMCON control
_WRT_OFF  EQU  H'3FFF'  ; Write protection off

;----- DEVID Equates --------------------------------------------------
_DEVID1  EQU  H'2006'

;----- IDLOC Equates --------------------------------------------------
_IDLOC0  EQU  H'2000'
_IDLOC1  EQU  H'2001'
_IDLOC2  EQU  H'2002'
_IDLOC3  EQU  H'2003'

LIST
Max.

Last edited:

#### cmartinez

Joined Jan 17, 2007
7,881
For instance, I can see that the internal oscillator can be configured through the OSCCON register, which is located in 10H, according to the memory map. But where the hell is the CONFIG register?

#### jpanhalt

Joined Jan 18, 2008
11,087
Thanks John ... I've located the Configuration Word description in the datasheet, and the function of each of its bits. What has me confused is that I'm thinking about the Configuration Word as a register, and that it might be accessed through move instructions, or by simply reading and writing its bits individually, but I'm seeing that maybe that's not the case.
"__Config" (notice the 2 underscores) is an Assembler directive t set the bits for your. You can also just use the hex equivalent. I will work that out for you and post an edit. I have never tried doing it with inline code. It may not work.

Edit: Those configuration bits must be Assembler specific. They are not recognized in MPLAB 8.92 nor the current datasheet. I have attached the .inc file for the configuration bits from MPLAB8.92.

The biggest difference is the oscillator settings. Usually one declares the type (e.g, HS, INTOSC w/ or w/o CLKIN, etc.) in the configuration word, then in OPTION_REG you set the frequency.

#### Attachments

• 2.3 KB Views: 9
Last edited: