Menu

PIC16F54 observations vs. other PIC's ...

ic-beau
2013-01-15
2013-05-30
  • ic-beau

    ic-beau - 2013-01-15

    In order to program a PIC16F54, I have to set the GCB to …

    #chip 16c54

    …in order for my programmer (DIY K149-BC v141204) to program the "F" part number.

    Also to note, a PIC16x54 does not have two instructions that most of the other chips have.  These are ADDLW and SUBLW.

    An example GCB code:

    [word]     Accumulator   = 0
                    Accumulator += 1
    

    Will cause an error in the compiler … "Unknown opcode 'addlw' and generates the following assembly code…

    clrf Accumulator
    clrf Accumulator_H
    movlw 1
    addwf Accumulator,F
    movf Accumulator_H,W
    btfsc STATUS,C
    addlw 1
    movwf Accumulator_H
    

    The workaround that I have used for WORD values is this and requires direct inline assembly …

    [word]     Accumulator   = 0
    movlw  1
    addwf  Accumulator,F
    btfsc STATUS,C
    incf Accumulator_H,F
    
     
  • ic-beau

    ic-beau - 2013-01-19

    Alternatively you could setup the counter like this …

    'Same as ....
    ' Accumulator = Accumulator + 1
    movlw 1
    addwf Accumulator,F
    btfsc STATUS,C
    addwf Accumulator_H,F
    btfsc STATUS,C
    goto OVERFLOW_routine
    

    Even for a 32-Bit Counter, something like this …

    movlw 1
    addwf Accumulator_A,F
    btfsc STATUS,C
    addwf Accumulator_B,F
    btfsc STATUS,C
    addwf Accumulator_C,F
    btfsc STATUS,C
    addwf Accumulator_D,F
    btfsc STATUS,C
    goto OVERFLOW_routine
    

    Where A/B/C/D are each BYTEs making up the 32-Bit LONG

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.