PDA

View Full Version : vấn đề chân A5 pic6f886 chế độ ADC


minh_thanh87
19-05-2013, 12:46 PM
không thể điều khiển mức logic của chân a5 xuống thấp code như sau:

#include <16F886.h>
#device *=16 adc=10

#FUSES NOWDT //no Watch Dog Timer
#FUSES HS //Crystal high
#FUSES NOPUT //No Power Up Timer
#FUSES PROTECT //protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#use delay(clock=20000000)
#use fast_io(B)
#use fast_io(A)
#use fast_io(C)

void main()
{

setup_adc_ports(sAN0|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_oscillator(False);
set_tris_A(0xCF); // 1100 1111//
set_tris_B(0x00);
set_tris_C(0x03);
while(1)
{
output_low(pin_a5);
delay_ms(500);
output_high(pin_a5);
delay_ms(500);
}
}



Mình đã nạp chạy thử thì lúc nào chân a5 cũng ở mức cao. mong các bạn giúp đỡ

quanghuy_125
19-05-2013, 07:12 PM
không thể điều khiển mức logic của chân a5 xuống thấp code như sau:

#include <16F886.h>
#device *=16 adc=10

#FUSES NOWDT //no Watch Dog Timer
#FUSES HS //Crystal high
#FUSES NOPUT //No Power Up Timer
#FUSES PROTECT //protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#use delay(clock=20000000)
#use fast_io(B)
#use fast_io(A)
#use fast_io(C)

void main()
{

setup_adc_ports(sAN0|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_oscillator(False);
set_tris_A(0xCF); // 1100 1111//
set_tris_B(0x00);
set_tris_C(0x03);
while(1)
{
output_low(pin_a5);
delay_ms(500);
output_high(pin_a5);
delay_ms(500);
}
}



Mình đã nạp chạy thử thì lúc nào chân a5 cũng ở mức cao. mong các bạn giúp đỡ

Bạn kiểm tra lại mạch xem nhé. Mình nạp vẫn chạy mà .
Hay là bạn có thể khai báo

void main()
{
setup_oscillator(OSC_8MHZ);
setup_adc_ports(sAN0|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_oscillator(False);
set_tris_A(0xCF); // 1100 1111//
set_tris_B(0x00);
set_tris_C(0x03);