PIC18F2550 - pini si program de start Email
Scris de gigipatrud   
Vineri, 24 Octombrie 2008 07:57

 Microcontrolerul scris cu programul de mai jos, alimentat cu +5V la VDD si - la cei doi pini VSS, va genera la pinii marcati ca iesire un semnal de 164KHz. Pinul 1 este intrare, iar pinii 15-1, desi se specifica ca ar fi intrare nu am reusit sa dezactivez total portul USB.

Pic182550 start point

;******************************************************************************
;   This file is a basic template for assembly code for a PIC18F2550. Copy    *
;   this file into your project directory and modify or add to it as needed.  *
;                                                                             *
;   Refer to the MPASM User's Guide for additional information on the         *
;   features of the assembler.                                                *
;                                                                             *
;   Refer to the PIC18Fx455/x550 Data Sheet for additional                    *
;   information on the architecture and instruction set.                      *
;                                                                             *
;******************************************************************************
;                                                                             *
;    Filename:                                                                *
;    Date:                                                                    *
;    File Version:                                                            *
;                                                                             *
;    Author:                                                                  *
;    Company:                                                                 *
;                                                                             *
;******************************************************************************
;                                                                             *
;    Files Required: P18F2550.INC                                             *
;                                                                             *
;******************************************************************************

    LIST P=18F2550        ;directive to define processor
    #include <P18F2550.INC>    ;processor specific variable definitions

;******************************************************************************
;Configuration bits
;Microchip has changed the format for defining the configuration bits, please
;see the .inc file for futher details on notation.  Below are a few examples.



;   Oscillator Selection:
      CONFIG FOSC = INTOSCIO_EC ;   Internal oscillator, port function on RA6, EC used by USB

;    CONFIG   FOSC = INTOSC_EC; Internal oscillator, CLKOUT on RA6, EC used by USB 
      CONFIG        WDT = OFF     ;        HW Disabled - SW Controlled
     CONFIG MCLRE = OFF ; RE3 input pin enabled; MCLR disabled 
     CONFIG PLLDIV = 1
;******************************************************************************
;Variable definitions
; These variables are only needed if low priority interrupts are used.
; More variables may be needed to store other special function registers used
; in the interrupt routines.

        CBLOCK    0x080
        WREG_TEMP    ;variable used for context saving
        STATUS_TEMP    ;variable used for context saving
        BSR_TEMP    ;variable used for context saving
        ENDC

        CBLOCK    0x000
        EXAMPLE        ;example of a variable in access RAM
        ENDC

;******************************************************************************
;EEPROM data
; Data to be programmed into the Data EEPROM is defined here

        ORG    0xf00000

        DE    "Test Data",0,1,2,3,4,5

;******************************************************************************
;Reset vector
; This code will start executing when a reset occurs.

        ORG    0x0000
        call init_abce
        goto    Main        ;go to start of main code

;******************************************************************************
;High priority interrupt vector
; This code will start executing when a high priority interrupt occurs or
; when any interrupt occurs if interrupt priorities are not enabled.

        ORG    0x0008

        bra    HighInt        ;go to high priority interrupt routine

;******************************************************************************
;Low priority interrupt vector and routine
; This code will start executing when a low priority interrupt occurs.
; This code can be removed if low priority interrupts are not used.

        ORG    0x0018

        movff    STATUS,STATUS_TEMP    ;save STATUS register
        movff    WREG,WREG_TEMP        ;save working register
        movff    BSR,BSR_TEMP        ;save BSR register

;    *** low priority interrupt code goes here ***


        movff    BSR_TEMP,BSR        ;restore BSR register
        movff    WREG_TEMP,WREG        ;restore working register
        movff    STATUS_TEMP,STATUS    ;restore STATUS register
        retfie

;******************************************************************************
;High priority interrupt routine
; The high priority interrupt code is placed here to avoid conflicting with
; the low priority interrupt vector.

HighInt:

;    *** high priority interrupt code goes here ***


        retfie    FAST

;******************************************************************************
;Start of main program
; The main program code is placed here.

init_abce
      BSF UCFG, UTRDIS
      BCF UCON, USBEN
;  BSF UCON, SUSPND

 ; BCF SSPCON1, SSPEN
      movlw .0
      movwf T1CON
      movwf T3CON
      clrf PORTA
      clrf PORTB
      clrf PORTC
      clrf PORTE
      clrf LATA
      clrf LATB
      clrf LATC
;  clrf LATE
      movlw 0Fh
      movwf ADCON1
      movlw 07h
      movwf CMCON
      movlw .0
      movwf TRISA
      movwf TRISB
      movlw b'00110000'
      movwf TRISC
;  BSF TRISE, 3
      movlw b'01110010'
      movwf OSCCON
      return


Main:
      movlw .255
      movwf PORTA
      movwf PORTB
      movwf PORTC
      nop
      nop
      movlw .0
      movwf PORTA
      movwf PORTB
      movwf PORTC

 
      goto Main
 

;******************************************************************************
;End of program

        END
Comments
Doar utilizatorii inregistrati pot scrie comentarii.!
gigi |2008-11-08 06:36
Interesant articol, pentru incepatori...
 
 
Statistici vizitatori: [+/-]
Azi:
Ieri:
Alaltaieri:
1241
1242
1310

-68
Saptamana asta:
Saptamana trecuta:
Cu 2 sapt. in urma:
3793
8387
9516

-1129
Luna asta:
Luna trecuta:
Acum doua luni:
26640
23361
0

+23361
Anul asta:
Anul trecut:
50001
0
+50001
Avem 71 vizitatori online