Postat: 17 maj 2007, 19:47:32
Visst har funderat på att använda PIC16F886-I/SO men det finns ju ingen som har den hemma så får förbli 16f876a ett tag till... Verkar som grossisterna inte fattat att den finns...
Svenskt forum för elektroniksnack.
https://elektronikforumet.com/forum/
Kod: Markera allt
;**********************************************************************
; This file is a basic code template for assembly code generation *
; on the PIC16F887. This file contains the basic code *
; building blocks to build upon. *
; *
; If interrupts are not used all code presented between the ORG *
; 0x004 directive and the label main can be removed. In addition *
; the variable assignments for 'w_temp' and 'status_temp' can *
; be removed. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler (Document DS33014). *
; *
; Refer to the respective PIC data sheet for additional *
; information on the instruction set. *
; *
;**********************************************************************
; *
; Filename: xxx.asm *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
; *
;**********************************************************************
; *
; Files required: *
; *
; *
; *
;**********************************************************************
; *
; Notes: *
; *
; *
; *
; *
;**********************************************************************
list p=16f887 ; list directive to define processor
#include <p16f887.inc> ; processor specific variable definitions
; '__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.
__CONFIG _CONFIG1, _LVP_OFF & _FCMEN_ON & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
__CONFIG _CONFIG2, _WRT_OFF & _BOR21V
;***** VARIABLE DEFINITIONS
w_temp EQU 0x71 ; variable used for context saving
status_temp EQU 0x72 ; variable used for context saving
pclath_temp EQU 0x73 ; variable used for context saving
;**tle spodaj da vse blabla EQU 0xZZ, kje jih lahko da, poglej v datasheet.
stevec EQU 0x20 ;general purpose stevec
stevec_1 EQU 0x21 ;tevec, ko delam z RAMom
;**tle spodaj da vse #define krneki neki druzga, kar jih ma.
#define RS PORTE,0
#define E PORTE,1
;tle spodaj da pa e tabele za EPROM, èe ga tvoj PIC ima. Naredi tako:
org 0x2100
de "ASCII v tabeli"
;ali pa tako
org 0x210E
de 0x00,0x01,0xFF
;**********************************************************************
ORG 0x000 ; processor reset vector
nop
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
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
;sem noter grejo interrupti. Rutine kveèjemu jih poklièe od tle,
;ne pa uporabljat GOTO.
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
; remaining code goes here
;Tle noter pa naprej kucka, kaj bo kje. Zaène nekako tako
;PORTA ON
;Nastavi PORTA na digitalen input
BCF STATUS,RP0 ;Bank 0
BCF STATUS,RP1 ;
CLRF PORTA ;Init PORTA
BSF STATUS,RP0 ;Bank 1
BCF STATUS,RP1 ;
MOVLW 0x07 ;Set RA<2:0> to
MOVWF CMCON0 ;digital I/O
CLRF ANSEL ;Make all PORTA I/O
MOVLW 0xFF ;Set RA<7:0> as inputs
MOVWF TRISA ;
BCF STATUS,RP0 ;Bank 0
BCF STATUS,RP1 ;
;in tako nastavi vso periferijo, ki jo misli rabit.
;Vse inicializacije, tudi za LCD, da tle, ali kot rutina
;ali kot klic rutine.
;potem naredi pa
start
;nekaj kode, ki more skoz laufat
;in se ti izvaja skozi. Kot while(1){} v C - ju
call subrutina1
goto start
;potem pa tu pie subrutine
subrutina1
;kup ukazov
nop
return
END ; directive 'end of program'
På vad sätt, menar du, att t.ex 19.1700MHz inte skulle vara ett fast värde?squiz3r skrev:Jag känner mig minst saggt lite korkad.. Först nu förstår jag att PIC'en bara vill ha fasta världen på kristallen.... Är det någon som har testat köra på något annat värde, tex. 19,1700Mhz?