PIC Assembler 12F683 W Register Memory Map Location

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
The one thing that is getting me.

Is the 'behind the scenes' thing that are done for you.

I was expecting Assembler to be very direct. One thing at a time.

Some of these 'simple' commands or keywords do two or more things at once.

Like Dos commands. Copy a to b. This PIC is not happening like that..
 

be80be

Joined Jul 5, 2008
2,395
MOVF A
MOVWF B

There is no copy A to B

Read page 57 to 64 of the data sheet for the 12F508 it's good for all the baseline chips.
 

JohnInTX

Joined Jun 26, 2012
4,787
Why bother? The assembler will do it for a much lower per hour rate. Assuming you get past being flummoxed by semi-cryptic error messages.
Yeah, but it won't save you from going down a rabbit hole.. That context would give a warning but would allow you your 'Murphy Moment' nonetheless. Just trying to keep 'em between the lines.
 

be80be

Joined Jul 5, 2008
2,395
Sorry I was half asleep.
The osscon setting is a waste of time but just do as they do and don't worry.
in the baseline chips. things to worry about is the code.
There right pick one chip and play with it for a long time.
learn what it can do and then move on.
I started with the 16f628 and Nigel Goodwin's samples of code in asm.
made all his boards on little perfboard. learned up on fine soldering that way lol
Then I grabbed me a 18f1220 because the guy that made the junebug a clone of the pickit2 sent me one cause some code I posted for using it somewhere I can't remember, But at that point I was using swordfish with the 18f chips and had got good with the datasheets reading that's the first thing I seen if you want use asm learn the data sheet of the chip it shows you everything.
 
Last edited:

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Bebe John and Bravo Thanks!

'RESET_VECTOR CODE 0xFF ; processor reset vector

; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value'

What does RESET_VECTOR mean?

How about CODE?

I don't see a list of Reserved words for PIC Assembler anywhere.
 

JohnInTX

Joined Jun 26, 2012
4,787
Bebe John and Bravo Thanks!

'RESET_VECTOR CODE 0xFF ; processor reset vector

; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value'

What does RESET_VECTOR mean?

How about CODE?

I don't see a list of Reserved words for PIC Assembler anywhere.
RESET VECTOR is where the code effectively starts after a reset. Certain goofy parts like the 10F may load the oscillator cal value in W but essentially, that's where your code starts.
CODE is a directive that tells the assembler to put the following statements into the CODE section - as opposed to DATA or other info. Used by the linker when assembling relocatable modules. Most small PICS assemble in absolute mode so CODE is not applicable. My personal opinion is that NO 8-bit PIC code is really relocatable due to the bank-switching and limited range of the various addressing modes.
Reserved words:
MPLAB->Help Topics->MPASM
http://ww1.microchip.com/downloads/en/devicedoc/mpasm_&_mplink_33014h.pdf
Easy!
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Okay. Here's the revised plan.

According to that post.

You can get by without loading calibration value to OSCAL.

We will go with that!

That leaves two issues.

The Gooligum switch in configuration bit which Microchip template leaves out.

Then the real deal. The Reset Vector line. That's to the best of knowledge.

Will concentrate on that line.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
This is what I'm referring to.

'
RESET_VECTOR CODE 0xFF ; processor reset vector

; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value.'

Now in the post the guy says you can even leave that out.

That it is done automatically on reset.

Will try it with and without.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
This post.

https://forum.allaboutcircuits.com/threads/pic-12f509-osccal-calibration-i-just-dont-get-it.41741/

Let me find the exact post in it.

#10

'For 12F509, this reset address is hard coded into the PIC PC and the instruction at 0x03FF will be executed after reset regardless of whether user has pointed the reset vector to it or not, nor you can change this behavior.

i.e. one don't have to explicitly add codes in a program for this to happen.

So for all practical purposes the user code START or RESET address can be considered to be 0x0000, with the W then containing a value which user can simply ignore or placed into OSCCAL for frequency adjustment.'

Somebody named Ebic388 from 2007.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
'
list p=12F509 ; list directive to define processor
#include <p12F509.inc> ; processor specific variable definitions'

Going to write our 'Load a Value To A Program Memory Address' program.

Starting out putting these two lines in.
 

MaxHeadRoom

Joined Jul 18, 2013
30,699
Still don't believe in starting with the templates supplied?o_O
Max.

Code:
;**********************************************************************
;   This file is a basic code template for object module code         *
;   generation on the PIC12F509. This file contains the               *
;   basic code building blocks to build upon.                         *
;                                                                     *
;   Refer to the MPASM User's Guide for additional information on     *
;   features of the assembler and linker.                             *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:      xxx.asm                                           *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:                                                          *
;    Company:                                                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files required: P12F509.INC                                      *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************

    list      p=12F509            ; list directive to define processor
    #include <p12F509.inc>        ; processor specific variable definitions

    __CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC

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




;***** VARIABLE DEFINITIONS
TEMP_VAR    UDATA
temp        RES     1             ;example variable definition






;**********************************************************************
RESET_VECTOR    CODE   0x3FF      ; processor reset vector

; Internal RC calibration value is placed at location 0x3FF by Microchip
; as a movlw k, where the k is a literal value.

MAIN    CODE    0x000
    movwf   OSCCAL            ; update register with factory cal value


start
    nop                       ; example code
    movlw   0xFF              ; example code
    movwf   temp              ; example code

; remaining code goes here





    END                       ; directive 'end of program'
 
Last edited:

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC

BTW These lines are from the 12F509 Microchip template.

Okay. There's that ' _IntRC_OSC' on the end.

We'll leave it. Will double check 10F200 template. Gooligum puts it on for 10F200 and Microchip doesn't.

Don't know what that means.

__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF

Check! 10F200 does not have it.
 
Last edited:
Top