Hi Tony, thanks for your attention. My doubts it is: Will it be that my initial configuration this correct one? __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_OFF & _XT_OSC & _WRT_ENABLE_OFF The led realy doesn't blink. I put on the osciloscope in the out (PORTC6), and nothing doesn't happen, it just is in 0. I am using PICSTART PLUS for play the PIC16F873. Regards. Anbar. > -----Mensagem Original----- > De: Tony Nixon > Para: > Enviada em: Segunda-feira, 7 de Fevereiro de 2000 20:03 > Assunto: Re: First Project with PIC16F87x doesn't work > > > > anbarsystem@ZAZ.COM.BR wrote: > > > > > > Hi All, > > > My first project with the PIC16F87X doesn't work. I am simply trying to > do a > > > conversion A/D in the PORTA0 and show it in PORTB with leds.Also a led > > > 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 & _XT_OSC > & > > > _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 > > mailto:sales@picnpoke.com >