> > > blinking in the PORTC6 using TMRO overflow. I'm using a 4MHZ cristal.
> > >
> > > See my Codes below.
> > >
> > > #DEFINE LED PORTC6
> > >
> > > list p=16f873
> > >
> > > include "p16f873.inc"
> > >
> > > __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_OFF &
> &
> > > _WRT_ENABLE_OFF
> > >
> >
> > Add this..
> >
> > Temp equ 20h ; temp timer register
> >
> >
> > > ;----------------------------------------------------
> > > ; Start at the reset vector
> > > org 0x000
> > >
> > > Start:
> > > clrf PORTA
> > > clrf PORTB
> > > clrf PORTC
> > > bsf STATUS,RP0
> > > movlw B'00000111' ;TMR0 prescaler, 1:256
> > > movwf OPTION_REG
> > > movlw b'00000001' ;PA0=IN
> > > movwf TRISA
> > > movlw b'00000000'
> > > movwf TRISB ;PB=OUT
> > > movlw b'00000000' ;PC=OUT
> > > movwf TRISC
> >
> > Try this value for ADCON1
> >
> > movlw b'00000100' ; RA0,1,3 = A2D, left justify
> >
> > > movlw b'00001110' ;VREF+ VDD E VREF- VSS, PORTA0 A/D IN
> > > movwf ADCON1
> > > bcf STATUS,RP0 ;Fosc/8, A/D ON
> >
> > Try this value for ADCON0
> >
> > movlw b'11000001' ; A2D = on, internal RC, chan 0
> >
> > > movlw b'01000001'
> > > movwf ADCON0
> > >
> >
> >
> > The LED may appear not to blink because the time it takes for TMR0 to
> > overflow at 4MHz is about 65mS. Try this...
> >
> > > MAIN:
> > movlw d'10'
> > movwf Temp
> > > clrf TMR0
> > TimeWt btfss INTCON,T0IF ;Wait for Timer0 to timeout
> > > goto $-1
> > > bcf INTCON,T0IF
> >
> > decfsz Temp
> > goto TimeWt
> >
> > > btfss LED
> > > goto LED_ON
> > > bcf LED
> > > goto SET_AD
> > >
> > > LED_ON:
> > > bsf LED
> > >
> > > SET_AD:
> > > bsf ADCON0,GO ;Start A/D conversion
> > >
> >
> > Try this code for conversion complete
> >
> > Wait nop
> > btfsc ADCON0,GO ; (bit 2) = 0, conv is complete
> > goto Wait
> >
> > > Wait:
> > > btfss PIR1,ADIF ;Wait for conversion to complete
> > > goto $-1
> > >
> > > movf ADRESH,W ;Write A/D result to PORTB
> > > movwf PORTB
> > > goto MAIN
> > >
> > > I would appreciate it if someone could make a suggestion.
> > >
> > > Thanks in advanced.
> > > Anbar.
> >
> > --
> > Best regards
> >
> > Tony
> >
> >
http://www.picnpoke.com
> >
sales
spam_OUTpicnpoke.com
>