Jump to content
Sign in to follow this  
mkbg12

Duvida - ADC 16f677

Recommended Posts

mkbg12

Boas pessoal. Com o programa seguinte supostamente ligaria 8 led's do porto C do pic16f677 lido o valor analogico quando comparado com vdd e registada a palavra no registo adresh que posteriormente colocava os bits do porto C com o valor do registo, mas ok e facto e k isso nao acontece, os bits nao sao todos activos para qualquer valor de tensao em AN0... e ja dei voltas e nada :S. alguem me pode ajudar?

Programa:

list p=16f677

#include <p16f677.inc>

errorlevel -302

__CONFIG _CP_OFF & _CPD_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _XT_OSC & _IESO_OFF & _BOR_OFF

T_Aquis EQU 0x20

ORG    0x000

goto    p_principal

ORG    0x004

RETFIE

p_principal

clrf PORTC

bsf STATUS, RP0

clrf TRISC

movlw B'00010000'

movwf ADCON1

bcf STATUS, RP0

movlw B'00000001'

movwf ADCON0

ini_aquis

movlw 0x40

movwf T_Aquis

decfsz T_Aquis,1

goto $-1

bsf ADCON0,GO

btfss ADCON0,GO

goto $-1

movlw ADRESH

movwf PORTC

goto ini_aquis

END

Cumps  :D

Share this post


Link to post
Share on other sites
asena

assim de repente, vi que ele nunca vai ficar naquele WHILE ::

bsf  ADCON0,GO

  btfss  ADCON0,GO

  goto  $-1

estás a activar o BIT, e saltas se o BIT for 1. Vai saltar sempre.

Se queres colocar o valor de ADRESH no W, então tens q usar a instrução MOVF ADRESH, W.

A que usas agora vai colocar no W o endereço de ADRESH.

configurações de periféricos nao confirmei

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.