PIC Assembler Observation

be80be

Joined Jul 5, 2008
2,072
You have lost your mind just kidding but you don't have to use 0x10 you could just use
b'00001010' or put radx dec and just use a 10

Keep away from using hex you'll be lost more then you are now.
Use bin 10101010 or dec 0 to 255
I stay with just bin cause you can see the bit's
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Burt

'Keep away from using hex'

Just to keep it simple.

I used hex because in datasheet register addresses are in hex.

'I stay with just bin'

Yes. I loaded register with a binary value.

Seems like everything is in order.

Program

MOVLW b'11111111'

MOVWF 0x10
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Max

Label?

My next step was to create a variable and see where it ends up with IPE.

That's my 'Mickey Mouse Club' debugger for the moment.

Label? I get that bad feeling it might be different than a variable.

Will look at datasheet and tutorial to gleen some info from them.
 
Last edited:

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
I will just throw this question in here instead of starting a new post.

Will the calibration data initialization code in the Microchip be stable?

Just being cautious.

Gooligum does it a little different. Will compare them later.
 

Attachments

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Here's Gooligum 10F200 program with internal oscillator inititialization code.


;***** RC CALIBRATION
RCCAL CODE 0x0FF ; processor reset vector
res 1 ; holds internal RC cal value, as a movlw k


;***** RESET VECTOR *****************************************************
RESET CODE 0x000 ; effective reset vector
movwf OSCCAL ; apply internal RC factory calibration

I guess I can fine tune it later.

Microchip template should work okay..
 

Attachments

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Here's template again.

;**********************************************************************
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.

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


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

I am a little suspicious of 0xFF showing up twice there.

I think Microchip might be trying to say something that can be trouble later.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Max

You say 12Fxxx include file.

I am working with 10F200.

Look at 12Fxxx anyway?

Where are the include files? How do I open them?
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Okay.

10F200 Include file is on the root in MPASM suite. Opened it with Notepad.

Saw a lot of EQU's but no T1CON.
 

MaxHeadRoom

Joined Jul 18, 2013
28,617
If you have MPLAB, go to directory, Program files/ Microchip/MASM suite and you will find all the *.inc files there, I think the very first is the 10f200!
Max.
 

MaxHeadRoom

Joined Jul 18, 2013
28,617
Okay.

10F200 Include file is on the root in MPASM suite. Opened it with Notepad.

Saw a lot of EQU's but no T1CON.
Because the 10f does not have one, I was mistaken, I thought you were using 12f.
It is still easier when you designate a memory location by label.
Max.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Max

'It is still easier when you designate a memory location by label.'

Sure.That first program just gets it done.

Not an example of 'Good Coding Practices' at all.
 

be80be

Joined Jul 5, 2008
2,072
This is what your using
Code:
    list        p=10F200          
    #include    <p10F200.inc>  


;***** CONFIGURATION
                ; ext reset, no code protect, no watchdog
    __CONFIG    _MCLRE_ON & _CP_OFF & _WDT_OFF


;***** RC CALIBRATION
RCCAL   CODE    0x0FF       ; processor reset vector
        res 1               ; holds internal RC cal value, as a movlw k


;***** RESET VECTOR *****************************************************
RESET   CODE    0x000       ; effective reset vector
        movwf   OSCCAL      ; apply internal RC factory calibration


;***** MAIN PROGRAM *****************************************************

;***** Initialisation
start   
        movlw   b'1101'         ; configure GP1 (only) as an output
        tris    GPIO
        movlw   b'0010'         ; set GP1 high
        movwf   GPIO

;***** Main loop               
        goto    $               ; loop forever


        END
This is mplab
Code:
    list      p=10F200            ; list directive to define processor
    #include <p10F200.inc>        ; processor specific variable definitions

    __CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF

; '__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   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.
   
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'
Do you not see "example code in this " mean it's just there to show you how.
Code:
start   
    nop                       ; example code
    movlw   0xFF              ; example code
    movwf   temp              ; example code

; remaining code goes here
 

be80be

Joined Jul 5, 2008
2,072
If you wrote some code using the template it would look like this
Code:
;**********************************************************************
;   This file is a basic code template for object module code         *
;   generation on the PIC10F200. 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: P10F200.INC                                      *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************

    list      p=10F200            ; list directive to define processor
    #include <p10F200.inc>        ; processor specific variable definitions

    __CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF

; '__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   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.
  
MAIN    CODE    0x000
    movwf   OSCCAL            ; update register with factory cal value


;***** Initialisation
start  
        movlw   b'1101'         ; configure GP1 (only) as an output
        tris    GPIO
        movlw   b'0010'         ; set GP1 high
        movwf   GPIO

;***** Main loop              
        goto    $               ; loop forever


        END
Please look at all 3 code post
 

be80be

Joined Jul 5, 2008
2,072
See this
Code:
movwf   temp
And this
Code:
[LIST=1]
[*];***** VARIABLE DEFINITIONS
[*]TEMP_VAR    UDATA
[*]temp        RES     1             ;example variable definition
[/LIST]
That little thing that said
temp RES 1
That means that you ask the compiler
to save a place called temp one byte after this
Code:
MAIN    CODE    0x000
    movwf   OSCCAL            ; update register with factory cal value
You can now move anything you want to temp as long as it fits in the byte.
Like this
Code:
movlw   0x04              ; example code
    movwf   temp              ; example code
Don't got be 0xFF they just used that cause it's easy
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Burt

That is all good stuff you are saying.

Let me finish my first program and run it a few times.

Then we'll do variables.

I just want to declare one variable. Then write a value to it and look at it with IPE.

Yeah. Slow but sure.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Burt

Okay. There.

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

You are saying that is the starting point. Good.
 
Top