BlackOps
Full Member level 5
- Joined
- Jan 1, 2005
- Messages
- 279
- Helped
- 14
- Reputation
- 28
- Reaction score
- 3
- Trophy points
- 1,298
- Location
- AZERBAIJAN
- Activity points
- 2,496
pic16f88 external oscillator
Hello, i am remaking AN580 from Microchip. to make it work under PIC16F88. remaked the code, and have built circuit in Proteusbut it doesnt seem to work at all... can anyone see whats wrong to code? thanks
Hello, i am remaking AN580 from Microchip. to make it work under PIC16F88. remaked the code, and have built circuit in Proteusbut it doesnt seem to work at all... can anyone see whats wrong to code? thanks
Code:
;***********************************************************************************
;
;
;
;
;***********************************************************************************
#include <p16F88.inc>
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_ON & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _XT_OSC ;_INTRC_IO
RESET_ADDR EQU 0x00
ISR_ADDR EQU 0x04
COMRAM_ADDR EQU 0x70
CBLOCK COMRAM_ADDR
status_temp
w_temp
count ; first count variable
count2 ; second count variable
ENDC
ORG RESET_ADDR
START
goto SETUP
ORG ISR_ADDR
;==================================================
PER_INT_V
BCF STATUS, RP0 ; Bank0
BTFSC PIR1, TMR1IF ; Timer1 overflowed?
GOTO T1_OVRFL ; YES, Service the Timer1 Overflow Interrupt
;
; Should NEVER get here
;
ERROR1 ; NO, Unknown Interrupt Source
BSF PORTB, 1 ; Toggle a port pin to indicate error
BCF PORTB, 1
GOTO ERROR1
;
T1_OVRFL
BCF PIR1, TMR1IF ; Clear Timer1 Interrupt Flag
MOVLW 0x80 ; Since doing key inputs, clear TMR1
MOVWF TMR1H ; for 1 sec overflow.
; Do Interrupt stuff here
movlw b'00000001'
xorwf PORTB,f
RETFIE ; Return / Enable Global Interrupts
;================================================================
;
;==============================================================
SETUP ; POWER_ON Reset (Beginning of program)
CLRF STATUS ; Do initialization (Bank0)
;--------------------
banksel TRISB
movlw b'11000000'
movwf TRISB
banksel PORTB
clrf PORTB
;banksel OSCCON
; movlw b'01100000' ; should be 4 mhz
; movwf OSCCON
;-----------------------
BCF T1CON, TMR1ON ; Timer1 is NOT incrementing
; Do Initialization stuff here
MOVLW 0x80 ; TIM1H:TMR1L = 0x8000 gives 1 second
MOVWF TMR1H ; overflow, at 32 KHz.
CLRF TMR1L ;
;
CLRF INTCON
CLRF PIR1
BSF STATUS, RP0 ; Bank1
CLRF PIE1 ; Disable all peripheral interrupts
;
BSF PIE1, TMR1IE ; Enable TMR1 Interrupt
;
; Initialize the Special Function Registers (SFR) interrupts
;
BCF STATUS, RP0 ; Bank0
CLRF PIR1 ;
BSF INTCON, PEIE ; Enable Peripheral Interrupts
BSF INTCON, GIE ; Enable all Interrupts
;
MOVLW 0x0E
MOVWF T1CON ; Enable T1 Oscillator, Ext Clock, Async, prescaler = 1
BSF T1CON, TMR1ON ; Turn Timer1 ON
;
MAINLOOP
SLEEP
GOTO MAINLOOP ; Sleep, wait for TMR1 interrupt
end