Pat, why are you using an ISR for the ADC?
Bala
--- In , "Patrick Reitelbach"
<preitelbach@y...> wrote:
> > THE PROGRAM written below is simulated using
MPLAB 6.13
version.
> > building is suceeded .....but problem is it
gets into an infinite
>
> I assume "building is suceeded" means is assembled OK. The code
as
> presented here will not assemble error free. The main label is
> missing.
>
> Other comment notes below.....
>
> When you run the simulation open the File Register window to see
the
> results of register operations.
>
> >
> > list pf675 ; list directive to define processor
> > #include <p12f675.inc> ; processor
> specificvariabledefinitions
> >
> > errorlevel -302 ; suppress message 302 from list
file
> >
> > __CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF
&
> > _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
> >
> > ; '__CONFIG' directive is used to embed configuration word
> > within .asm file.
> > ; The lables following the directive are located in the
> > respective .inc file.
> > ; See data sheet for additional information on configuration word
> > settings.
> >
> >
> >
> >
> > ;***** VARIABLE DEFINITIONS
> > w_temp EQU 0x20 ; variable used for context
> saving
> > status_temp EQU 0x21 ; variable used for context
saving
> >
> >
> >
> >
> >
>
> ;*******************************************************************
> **
> > *
> > ORG 0x000 ; processor reset vector
> > goto main ; go to beginning of program
> >
> >
> > ORG 0x004 ; interrupt vector location
>
> ;*** start here *******
> > 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
> >
> >
> > ; isr code can go here or be located as a call subroutine
elsewhere
> >
> >
> > 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
> ;*** end here *****
> ; What does the above code do? Is it needed?
>
> > retfie ; return from interrupt
> >
> >
> >
> >
> > ; remaining code goes here
>
> ;*** start here ***
> > cmcon equ 19h
> > gpio equ 05h
> > status equ 03h
> > trisio equ 85h
> > adcon0 equ 1fh
> > ansel equ 9Fh
> > adresl equ 9Eh
> > adresh equ 1Eh
> > pir1 equ 0Ch
> ;*** end here ****
> ; really do not need to have this code section. Why?
>
> >
> >
> > bcf status,5
> > clrf gpio
> > movlw 07h
> > movwf cmcon
> > bsf status,5
>
> > movlw 60h ; cannot put 0x60 into TRISIO
> > movwf trisio ; need to set TRISIO for input on pins
> ; to be used as analog inputs. This code
> ; does not do it.
>
> > bcf status,5
>
> > movlw 3Fh
> > movwf gpio ; Why do this?
>
> ;*** start here ***
> > bsf ansel,6 ; sets ADC clock source to FRC
> > bsf ansel,5 ; the internal 4MHz system clock
> > bsf ansel,4 ; is selected above in _CONFIG
> ; read Table 7-1 notes for why
> ; this code is wrong
> ;*** end here ***
>
> > bsf adcon0,7
> > ADC bsf adcon0,1 ; the ADC has not been turned on yet
> > btfsc adcon0,1 ; so the bit will never be cleared
> > goto ADC
> > bcf pir1,6
> >
>
> ;*** start here ***
> > ; initialize eeprom locations
> >
> > ORG 0x2100
> > DE 0x00, 0x01, 0x02, 0x03
> ;*** end here ***
> ;What is this code for?
>
> >
> >
> > END ; directive 'end of program'
|