PIC Assembler 10F200 Light an LED Program

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Code:
;************************************************************************
;                                                                       *
;   Filename:      BA_L1-Turn_on_LED-10F200.asm                         *
;   Date:          19/9/12                                              *
;   File Version:  1.1                                                  *
;                                                                       *
;   Author:        David Meiklejohn                                     *
;   Company:       Gooligum Electronics                                 *
;                                                                       *
;************************************************************************
;                                                                       *
;   Architecture:  Baseline PIC                                         *
;   Processor:     10F200                                               *
;                                                                       *
;************************************************************************
;                                                                       *
;   Files required: none                                                *
;                                                                       *
;************************************************************************
;                                                                       *
;   Description:    Lesson 1, example 1                                 *
;                                                                       *
;   Turns on LED.  LED remains on until power is removed.               *
;                                                                       *
;************************************************************************
;                                                                       *
;   Pin assignments:                                                    *
;       GP1 = indicator LED                                             *
;                                                                       *
;************************************************************************

    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
 
Last edited:

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Are those labels?

RCAL and RESET?

They are right after Configuration.Which brings up another question.

Is _CONFIG a label or reserved word?
 
Are those labels?

RCAL and RESET?

They are right after Configuration.Which brings up another question.

Is _CONFIG a label or reserved word?
RCAL and RESET are labels.
Standard stuff. Note that CODE directive. Learn what that tells the Linker, along with the memory map of the 10F200 and you will understand what he is doing at those two points,

__CONFIG is an Assembler directive used to specify the configuration bits.
 

MaxHeadRoom

Joined Jul 18, 2013
28,702
@PICNewbee Use CODE=ASM

Code:
;***** 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
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Raymond Thanks!

Those are some 'right on the money' answers.

'Common sense isn't very common anymore.'

Max

Okay. Will get back to you about that after break time here.
 

be80be

Joined Jul 5, 2008
2,072
I think they look the same just the asm adds highlighting
Code:
movlw 0x70
movf  Temp
Code:
movlw 0x70
movf Temp
oh and the dumb code button don't list asm as a option.
 
Last edited:

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Max

Okay. How do you make it 'Code=ASM'?

Bebe

Might as well learn something. I was lucky to get it full size period.

Thanks!
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Max

Okay. In that post you said 'Code=ASM with square brackets'

I can put that in square brackets.

Then where does it go?
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Bebe

Thank you!

That looks better!

I think finding Microchip documentation for 'CODE' is going to be a 'can of worms'.

There's something about it in tutorial.

I can't cut and paste that because it's locked .PDF.
 

JohnInTX

Joined Jun 26, 2012
4,787
change these { to this [

{code=asm}code goes here {/code}
in the edit box
be8obe is referring to CODE tags in the AAC editor, not the CODE segment used in programming. Using CODE tags puts source code in a scrollable window. Adding a language specifier like code=ASM or code=MPASM (for Microchip) will highlight keywords and things.

Since you are muckking around in low end PICs, use the ABSOLUTE build mode and ignore segments like CODE, DATA etc. Those things are for building relocatable modules for the linker. Leave that be for now.

FWIW: There is a list of code tags you can use manually here:
https://forum.allaboutcircuits.com/threads/small-improvement-to-code-tag.113254/
 
Last edited:

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
John

Crossed wires here. Figured out the Code ASM thing.Thank you.

I am digging into CODE linker? directive.

'Note that CODE directive. Learn what that tells the Linker, along with the memory map of the 10F200 and you will understand what he is doing at those two points,'

That from this topic above there.

Tutorial has pretty good explanation of it.
 
/-/

Since you are muckking around in low end PICs, use the ABSOLUTE build mode and ignore segments like CODE, DATA etc. Those things are for building relocatable modules for the linker. Leave that be for now.
/-/
I see your point, but he is, apparently, trying to understand a short program written by someone else.

when CODE is followed by the address as in:
RESET CODE 0x000
it is not relocatable. Seems to me that it is no different than using:
ORG 0x000

So, my two cents is that if he wants to understand that program, learn what CODE does - or use another example :)
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you George

I get this feeling it is in Assembler help.

Will pick this up tomorrow.

'he wants to understand that program'

That's the picture!
 

JohnInTX

Joined Jun 26, 2012
4,787
I see your point, but he is, apparently, trying to understand a short program written by someone else.

when CODE is followed by the address as in:
RESET CODE 0x000
it is not relocatable. Seems to me that it is no different than using:
ORG 0x000

So, my two cents is that if he wants to understand that program, learn what CODE does - or use another example :)
+1 on learning the CODE directive.

FWIW, MPASM expects the CODE directive to be used in the relocatable mode. When it is used with an address like 0x000, it fixes the address of that segment only. Another use would be to locate the interrupt vectors. Other CODE segments without an address specified can be relocated at link time.

MPASM expects ORG to be used in the absolute mode. Under the hood, though, absolute code is still 'linked'. The ORG directive generates a CODE segment using the same syntax as relocatable code so there is lots of interchangability between the two modes. The multiple ORGs frequently found in absolute mode generate multiple 'relocatable ' segments that just happen to have fixed starting addresses. The assembler output is the same for both modes and the linker treats them the same.

CODE and ORG are covered in chapter 4 of the MPASM/MPLINK User's Guide.
http://ww1.microchip.com/downloads/en/DeviceDoc/33014L.pdf
 

be80be

Joined Jul 5, 2008
2,072
What's funny is I been fooling with these for 8 years I use this as a starting point change the chip as needed
and never really worried about CODE only a time or too but I found writing and seeing what works was better then anything I could do to learn how to progam a pic chip.
Code:
;**********************************************************************

list      p=12F508            ; list directive to define processor
#include <p12F508.inc>        ; processor specific variable definitions
       ;change to chip used

__CONFIG   _MCLRE_OFF & _CP_OFF & _WDT_OFF & _IntRC_OSC ;change for chip

; pin assignments
  
#define  TX  GPIO,0  ; transmit pin on GP0



;***** VARIABLE DEFINITIONS
      UDATA         
counter    res    1
Count      res    1


;**********************************************************************


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

RESET   CODE    0x000           ; effective reset vector
      
      
Start      
        ; code here
      
        goto Start ;loop for ever
      
delay                 ; timing delay for needed delay

    movlw 0x17
    movwf  Count 
Wait   
    nop
    decfsz Count ,f
    goto   Wait
    return

END  ; directive 'end of program'
With the data sheet and any chip I start with a led and set it up and make it blink
then move on to what i wanted to do
 
Top