• AVR Freaks

Hot!PIC16F877A Startup File

Page: 12 > Showing page 1 of 2
Author
The Loner
Super Member
  • Total Posts : 570
  • Reward points : 0
  • Joined: 2016/12/18 10:59:17
  • Location: 0
  • Status: offline
2019/04/02 21:33:52 (permalink)
0

PIC16F877A Startup File

 
Where do I find the include file in MPLAB X to read?
 

;Change RC_OSC to LP_OSC
    
    list p=16f877a ; list directive to define processor
    #include <p16f877a.inc> ; processor specific variable definitions
    
    __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF

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

;***** VARIABLE DEFINITIONS (examples)

; example of using Shared Uninitialized Data Section
INT_VAR UDATA_SHR
w_temp RES 1 ; variable used for context saving
status_temp RES 1 ; variable used for context saving
pclath_temp RES 1 ; variable used for context saving

; example of using Uninitialized Data Section
TEMP_VAR UDATA ; explicit address specified is not required
temp_count RES 1 ; temporary variable (example)

; example of using Overlayed Uninitialized Data Section
; in this example both variables are assigned the same GPR location by linker
G_DATA UDATA_OVR ; explicit address can be specified
flag RES 2 ; temporary variable (shared locations - G_DATA)

G_DATA UDATA_OVR
count RES 2 ; temporary variable (shared locations - G_DATA)

;**********************************************************************
RESET_VECTOR CODE 0x0000 ; processor reset vector
    nop ; nop for icd
    pagesel start
    goto start ; go to beginning of program


INT_VECTOR CODE 0x0004 ; interrupt vector location

INTERRUPT

    movwf w_temp ; save off current W register contents
    movf STATUS,w ; move status register into W register
    movwf status_temp ; save off contents of STATUS register
    movf PCLATH,w ; move pclath register into w register
    movwf pclath_temp ; save off contents of PCLATH register

; isr code can go here or be located as a call subroutine elsewhere

    movf pclath_temp,w ; retrieve copy of PCLATH register
    movwf PCLATH ; restore pre-isr PCLATH register contents
    movf status_temp,w ; retrieve copy of STATUS register
    movwf STATUS ; restore pre-isr STATUS register contents
    swapf w_temp,f
    swapf w_temp,w ; restore pre-isr W register contents
    retfie ; return from interrupt

MAIN_PROG CODE

start

    nop ; code starts here (example)
    banksel count ; example
    clrf count ; example

; remaining code goes here

    goto $
    END ; directive 'end of program'



Everything on the net.
Everything you see.
0's and 1's.
 
 
 
 
 
 
 

 
 
 
 
 
#1

24 Replies Related Threads

    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/02 21:46:40 (permalink)
    0
     
    That is solved.They are in the 'root' so to speak of the assembler directory.
     
    Where Templates is a directory but includes are just in the directory.
     
    They keep fooling me with that one!:)
     

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #2
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/02 22:36:53 (permalink)
    0
     
    If I do not intend to use variables is it okay to delete variables section to declutter code?

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #3
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/03 00:21:06 (permalink)
    +2 (2)
    I know I'm going to regret asking, but
    what sort of program are you going to write that does not use ANY variables?
     
     
    post edited by qhb - 2019/04/03 00:22:11

    Nearly there...
    #4
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/03 13:22:11 (permalink)
    0
     
    Thank you for the response.
     
    Let me get back to you in about 5 hours.
     
    It's been an interesting morning here.

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #5
    jack@kksound
    code tags!
    • Total Posts : 3188
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/03 13:37:34 (permalink)
    +1 (1)
    picmicrocontrolleruser
     
    If I do not intend to use variables is it okay to delete variables section to declutter code?


    A simple answer is YES, if you do not need it then delete it. Same goes for other sections of the "template" you have. It is just uncommon to use a pic and not use any RAM. Certainly possible just unusual.
    #6
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/03 19:22:41 (permalink)
    0
     
    'what sort of program are you going to write that does not use ANY variables?'
     
    Wait a minute.That's answering a question with another question.
     
    'A simple answer is YES, if you do not need it then delete it'
     
    Okay.I will delete that section.
     
    'Same goes for other sections of the "template" you have.'
     
    Can I delete the EEPROM section?
     
     

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #7
    PStechPaul
    Super Member
    • Total Posts : 2268
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/03 20:32:28 (permalink)
    0
    You just need to define what you want to do. You can blink an LED without using variables or EEPROM (but I don't see an EEPROM section). You can also get rid of the ISR, as you do not have any interrupts or peripherals enabled. I think you must enjoy making things hard for yourself, but have fun!

     
    #8
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/03 21:18:26 (permalink)
    +4 (4)
    picmicrocontrolleruser
     
    'what sort of program are you going to write that does not use ANY variables?'
     
    Wait a minute.That's answering a question with another question.

    Yeah, I tend to do that when it's a plainly stupid question.
     

    Nearly there...
    #9
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/03 21:22:58 (permalink)
    0
    'You just need to define what you want to do'
     
    Light an LED.
     
    'without using variables or EEPROM (but I don't see an EEPROM section)'
     
    My mistake.
     
    'You can also get rid of the ISR' Done.

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #10
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/03 21:28:10 (permalink)
    -4 (4)
     
    Post #9 reported to moderator.

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #11
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/03 23:50:51 (permalink)
    0

    ;Change RC_OSC to LP_OSC
        
        list p=16f877a ; list directive to define processor
        #include <p16f877a.inc> ; processor specific variable definitions
        
        __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF

    ;**********************************************************************
    RESET_VECTOR CODE 0x0000 ; processor reset vector
        nop ; nop for icd
        pagesel start
        goto start ; go to beginning of program



    MAIN_PROG CODE

    start

        nop ; code starts here (example)
        banksel count ; example
        clrf count ; example

    ; remaining code goes here

        goto $
        END ; directive 'end of program'

     
    Here is edited code.
     
    That's all for today.That's for sure!

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #12
    PStechPaul
    Super Member
    • Total Posts : 2268
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/04 00:42:19 (permalink)
    +2 (2)
    It won't build...
     
    I'll let you figure out why.

     
    #13
    crosland
    Super Member
    • Total Posts : 1580
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Bucks, UK
    • Status: online
    Re: PIC16F877A Startup File 2019/04/04 03:06:21 (permalink)
    +1 (1)
    picmicrocontrolleruser
     
    Post #9 reported to moderator.


    You are going to go far ith such a thin skin.
     
    You don't need the template. You can start a project from a completely blank file with no sections. Just add what you need.
    #14
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/10 22:35:54 (permalink)
    0
     
    Is connecting VDD and VSS to pins 11 and 12 the same as connecting them to 31 and 32?
     
    Thanks.
    post edited by Total Amateur - 2019/04/10 22:42:57

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #15
    crosland
    Super Member
    • Total Posts : 1580
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Bucks, UK
    • Status: online
    Re: PIC16F877A Startup File 2019/04/11 00:21:38 (permalink)
    +1 (1)
    picmicrocontrolleruser
     
    Is connecting VDD and VSS to pins 11 and 12 the same as connecting them to 31 and 32?
     
    Thanks.




    No. Regardless of which package you are using, but didn't bother to tell us. Some don't even have pins 31 and 32.
     
    You must connect ALL Vss and Vdd to the appropriate voltages.
     
    I refer the honourable gentleman to post #9.
     
    #16
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/11 00:31:39 (permalink)
    0
     
    PIC16F877A.
     
    Light's out here.Getting late.

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #17
    crosland
    Super Member
    • Total Posts : 1580
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Bucks, UK
    • Status: online
    Re: PIC16F877A Startup File 2019/04/11 02:35:03 (permalink)
    +5 (5)
    You still haven't said which package.
     
    picmicrocontrolleruser
     
    PIC16F877A.
     
    Light's out here.Getting late.




    The lights are on but no one is home.
    #18
    Antipodean
    Super Member
    • Total Posts : 1706
    • Reward points : 0
    • Joined: 2008/12/09 10:19:08
    • Location: Didcot, United Kingdom
    • Status: online
    Re: PIC16F877A Startup File 2019/04/11 05:42:50 (permalink)
    +3 (3)
    crosland
    You still haven't said which package.
     
    picmicrocontrolleruser
     
    PIC16F877A.
     
    Light's out here.Getting late.




    The lights are on but no one is home.




    I think only the 0's have been programmed ...
     

    Do not use my alias in your message body when replying, your message will disappear ...

    Alan
    #19
    1and0
    Access is Denied
    • Total Posts : 9257
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC16F877A Startup File 2019/04/11 11:47:08 (permalink)
    0
    ... and the OP got a new alias added to his long list.
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5