#2 KIIV
Předpokládám že to je chyba programu, hlavně nějakého nastavení :) Právě proto jsem to uvedl přesně, jestli by mi někdo neporadil co mají ty vývody společného. Jsem v podstatě začátečník, takže přijímám jakékoliv rady na zlepšení programu... Po tomto následuje už spínání. Používám vnitřní oscilátor 8MHz a nepoužívám přerušení. Prvním kamenem úrazu bylo, že není template.
list p=18f97j94 ; list directive to define processor
#include <p18f97j94.inc> ; processor specific variable definitions
CONFIG XINST = OFF, STVREN = OFF, CP0 = OFF, BOREN = OFF, IESO = OFF, CLKOEN = OFF, SOSCSEL = DIG, FOSC = FRC, EASHFT = OFF, IOL1WAY = OFF, WDTEN = OFF, DSBITEN = OFF, RETEN = ON
;***** VARIABLE DEFINITIONS
w_temp EQU 0x7D ; variable used for context saving
status_temp EQU 0x7E ; variable used for context saving
pclath_temp EQU 0x7F ; variable used for context saving
delay EQU 0xD80
delay2 EQU 0xD81
;**********************************************************************
ORG 0x000 ; processor reset vector
nop ; nop required for icd
goto nastaveni ; go to beginning of program
ORG 0x008 ; 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
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
nastaveni
;**********************NASTAVENI PORTU*************************************
;NASTAVENI PORTA + analog vstupy a A/D prevodnik
BANKSEL ANCON1 ;banka E
clrf ANCON1 ;vypnuti analogovych vstupu RA012345, RF2, RG0
clrf ANCON2 ;vypnuti analogovych vstupu RC2, RF567, RG1234
clrf ANCON3 ;vypnuti analogovych vstupu RH01234567
BANKSEL PORTA ;banka F
bcf ADCON1H, ADON ;vypnuti A/D prevodniku
clrf PORTA ;nulováni portu A
clrf TRISA ;PORTA nastaven jako vystupni
;NASTAVENI PORTB
clrf PORTB ;nulovani portu B
clrf TRISB ;PORTB vystupni
;NASTAVENI PORTC
clrf PORTC ;nulovani portu C
clrf TRISC ;PORTC vystupni
;NASTAVENI PORTD
clrf PORTD ;nulovani portu D
clrf PORTD ;PORTD vystupni
;NASTAVENI PORTE
clrf PORTE ;nulovani portu E
clrf TRISE ;PORTE vystupni
;NASTAVENI PORTF
clrf PORTF ;nulovani portu F
clrf TRISF ;PORTF vystupni
;NASTAVENI PORTG
clrf PORTG ;nulovani portu G
bcf CM1CON,CON ;vypnuti komparatoru
clrf TRISG ;PORTG vystupni
;NASTAVENI PORTH
clrf PORTH ;nulovani portu H
clrf TRISH ;PORTH vystupni
;NASTAVENI PORTJ
clrf PORTJ ;nulovani portu J
clrf TRISJ ;PORTJ vystupni
;NASTAVENI PORTK
BANKSEL PORTK ;banka E
clrf PORTK ;nulovani portu K
clrf TRISK ;PORTK vystupni
;NASTAVENI PORTL
clrf PORTL ;nulovani portu L
clrf TRISL ;PORTL vystupni
;ZHASNUTI VRSTEV
BANKSEL PORTA ;banka F
bsf PORTE,7 ;vypnuti vsrtev
bsf PORTE,6 ;vypnuti vsrtev
bsf PORTE,5 ;vypnuti vsrtev
bsf PORTE,4 ;vypnuti vsrtev
bsf PORTG,7 ;vypnuti vsrtev
;*****************OSTATNI NASTAVENI**************************************
BANKSEL OSCCON3 ;banka F
clrf OSCCON3 ;zruseni deleni frekvence oscilatoru
BANKSEL REFO1CON1 ;banka E
movlw 0x03
movwf REFO1CON1 ;nastaveni oscilatoru
movwf REFO2CON1 ;nastaveni oscilatoru
movlw 0xFF
movwf PMD0 ;vypnuti periferii ccp
movwf PMD1 ;vypnuti periferii usart ssp
clrf PMD2 ;zapnuti periferii timer
movlw 0xFF
movwf PMD3 ;vypnuti periferii lcd refo psp, str 83
movwf PMD4 ;vypnuti periferii usb cmp
BANKSEL RCON ;banka F
bcf RCON, IPEN ;priority interrupt disable
BANKSEL MEMCON ;banka E
bsf MEMCON, EBDIS ;nastaveni externi sbernice
clrf TRISD
;USB
bcf UCON, USBEN ;vypnuti USB
BANKSEL USTAT
clrf USTAT
BANKSEL UCFG
clrf UCFG
bsf UCFG,UTRDIS
;PRERUSENI
BANKSEL INTCON ;banka F
clrf INTCON ;vypnuti preruseni
;PORTY
clrf PADCFG1 ;vypnuti pull-up
BANKSEL ODCON1 ;banka E
clrf ODCON1 ;vypnuti open drain
clrf ODCON2 ;vypnuti open drain
;LCD
bcf LCDCON, 7 ;vypnuti LCD
;real time and clock
BANKSEL RTCCON1 ;banka F
bcf RTCCON1, RTCEN ;vypnuti casu a data
bcf ALRMCFG, ALRMEN ;vypnuti alarmu
;komparator
bcf CM1CON, CON ;vypnuti comparatoru
bcf CM2CON, CON ;vypnuti comparatoru
bcf CM3CON, CON ;vypnuti comparatoru
;pripadne pokracuj od strany 525
;******* TIMER na str 281-295 **********************************
clrf T0CON ;vypnuti TIMER 0
movlw 0x01
movwf T1CON ;vypnuti citani vsech timeru
movwf T3CON
movwf T5CON
movlw 0x04
movwf T2CON
movwf T4CON
movwf T6CON
movwf T8CON
;******DELAYS**************
clrf delay
clrf delay2
clrf TRISF ;znovu nastaven kvuli sbernici
clrf PORTF