⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initialize_f690.asm

📁 Synchronous Serial Communications (SSC) is a synchronous serial communications protocol between
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;----------------------------------------------------------------------
; 
; Copyright 2005 Microchip Technology Inc.
; 
; Microchip Technology Inc. ("Microchip") licenses this software to
; you solely for use with Microchip products. The software is owned
; by Microchip and is protected under applicable copyright laws. All
; rights reserved.
; 
; SOFTWARE IS PROVIDED IN AN "AS IS." MICROCHIP EXPRESSLY DISCLAIMS ANY
; WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
; PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP
; BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL
; DAMAGES, LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
; PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
; BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
; ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS.
; 
;----------------------------------------------------------------------
;
;   Filename:           initialize_f690.asm
;   Microcontroller:    PIC16F690
;   Assembled using:    MPLAB IDE v7.20
;
;   Author:             Steven Bible
;   Company:            Microchip Technology Inc.
;
;----------------------------------------------------------------------
;
;   Program Description:
;
;   Initialize the PIC16F690 to known initial values.
;
;----------------------------------------------------------------------
;
;   Revision History:
;
;   Ver. 0.1 - 2005-08-29: Initial write
;
;----------------------------------------------------------------------

    errorlevel  -302                ; suppress message 302 from list file

;----------------------------------------------------------------------
; Include Files
;----------------------------------------------------------------------

#include    "main.inc"              ; Project defines

;----------------------------------------------------------------------
; Global Defines
;----------------------------------------------------------------------

    ; Place the following #define directives in the main.inc file

;#define PORT_A_TRIS  b'<value>'
;#define PORT_B_TRIS  b'<value>'
;#define PORT_C_TRIS  b'<value>'

;----------------------------------------------------------------------
; Local Defines
;----------------------------------------------------------------------

; None

;----------------------------------------------------------------------
; Variables
;----------------------------------------------------------------------

;--------------------
; Uninitialized Data Section
;
; The RES directive reserves space for data storage.

;        udata

; none

;--------------------
; Shared Uninitialized Data Section
;
; Variables that are allocated in RAM that ais shared across all RAM banks (unbanked RAM). 
; The RES directive reserves space for data storage.

;        udata_shr

; none

;--------------------
; Global Variables
;
; Variables defined in this module that are made available to other 
; modules. The <label> must be defined prior to using the GLOBAL
; directive in this module. 

;    global  <label>


;----------------------------------------------------------------------
; Begin Executable Code Segment
;----------------------------------------------------------------------

;[<label>]  code    [<ROM_Address>]

        code

;----------------------------------------------------------------------
; Subroutine: Initialize PIC16F690
;   
; Description: 
;   
; Constants: 
;   
; Global Variables: 
;   
; Initialization: 
;   
; Output: 
;   
;----------------------------------------------------------------------

init_f690
    global  init_f690

;----------------------------------------
; Clock Sources (Section 3.0)
;
; The PIC16F690 can be configured in one of eight oscillator modes via
; the FOSC bits in the Configuration Word (Section 15). Refer to the 
; Configuration Bits section above for oscillator modes.
;
; Internal Clock Modes (Section 3.3.4)
;
; The PIC16F690 has two independant internal oscillators:
;   - a calibrated HFINTOSC (8 MHz), and
;   - an uncalibrated LFINTRC (31 kHz)
; The 8 MHz HFINTOSC drives a postscaler and multiplexer which can 
; provide one of six clock frequencies:
;
;   IRCF2  IRCF1  IRCF0
;     0      0      0    =   31 kHz
;     0      0      1    =  125 kHz
;     0      1      0    =  250 kHz
;     0      1      1    =  500 kHz
;     1      0      0    =    1 MHz
;     1      0      1    =    2 MHz
;     1      1      0    =    4 MHz
;     1      1      1    =    8 MHz

        banksel OSCCON              ; Bank 1

        ; IRCF2:IRCF0 = 111 -> 8 Mhz
        bsf     OSCCON, IRCF2       ; Internal Oscillator Frequency Select bit 2
        bsf     OSCCON, IRCF1       ; Internal Oscillator Frequency Select bit 1
        bsf     OSCCON, IRCF0       ; Internal Oscillator Frequency Select bit 0

;----------------------------------------
; Oscillator Tuning (OSCTUNE) Register (Section 3.4.2.1)
;
; The 8 MHz INTOSC's has been calibrated at the factory. It can be
; adjusted by writing to the OSCTUNE register. The OSCTUNE register
; is 5 bits long and has a tuning range of plus and minus 12 percent.

;                 xxx43210
        movlw   B'00000000'         ; Set OSCTUNE to center frequency
        movwf   OSCTUNE

;----------------------------------------
; Clock Sources and Oscillator Switching (Section 3.5)
;
; The PIC16F690 can switch the system clock source between the external
; and internal oscillators via the System Clock Select (SCS) bit.

        bcf     OSCCON, SCS         ; system clock source comes from the
                                    ; oscillator mode configured by the FOSC bits

;----------------------------------------
; I/O Ports (Section 4)
;
; Clear I/O Ports

        banksel PORTA               ; Bank 0

        clrf    PORTA
        clrf    PORTB
        clrf    PORTC

; Store PORT_A_TRIS, PORT_B_TRIS and PORT_C_TRIS values defined in main.inc
; into the TRISA, TRISB and TRISC direction registers

        banksel TRISA               ; Bank 1

        movlw   PORT_A_TRIS
        movwf   TRISA

        movlw   PORT_B_TRIS
        movwf   TRISB

        movlw   PORT_C_TRIS
        movwf   TRISC

;----------------------------------------
; PORTA Weak Pull-up Register (WPUA) (Section 4.2.1)
;
; Each of the PORTA pins, except RA3, has an individually configurable
; weak internal pull-up. Control bits WPUAx enable or disable each 
; pull-up. Refer to Register 4-3. Each weak pull-up is automatically
; turned off when the port pin is configured as an output. The pull-ups
; are disabled on a Power-on Reset by the /RAPU bit (see OPTION Register
; below).

        banksel WPUA                ; Bank 1

;    PORTA Pins = xx54x210
        movlw   B'00000000'         ;  no pull-ups enabled
        movwf   WPUA

;----------------------------------------
; PORTB Weak Pull-up Register (WPUB) (Section 4.4.1)
;
; Each of the PORTB pins has an individually configurable weak internal
; pull-up. Control bits WPUB<7:4> enable or disable each pull-up. Refer
; to Register 4-8. Each weak pull-up is automatically turned off when 
; the port pin is configured as an output. The pull-ups are disabled on
; a Power-on Reset by the /RAPU bit (see OPTION Register).

        banksel WPUB                ; Bank 2

;    PORTB Pins = 7654xxxx
        movlw   B'00000000'         ; no pull-ups enabled
        movwf   WPUB

;----------------------------------------
; PORTA Interrupt-on-Change Register (IOCA) (Section 4.2.2)
;
; Each of the PORTA pins is individually configurable as an interrupt-
; on-change pin. Control bits IOCAx enable or disable the interrupt 
; function for each pin. Refer to Register 4-4. The interrupt-on-change
; is disabled on a Power-on Reset.
;
; Note: Global, port change, and peripheral interrupt enables 
;       (GIE, RAIE and PEIE) must be enabled for individual interrupts
;       to be recognized (see INTCON register below).

        banksel IOCA                ; Bank 1

;    PORTA Pins = xx54x210
        movlw   B'00000000'         ; PORTA interrupt-on-change disable
        movwf   IOCA

;----------------------------------------
; PORTB Interrupt-on-Change Register (IOCB) (Section 4.4.2)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -