![]() |
lập trình đọc ADC với PIC18f4431
các pro cho em hỏi chút em sử dụng PIC18f4431 đê đọc ADC nhưng kết quả hiển thị LDC không đúng kết quả chỉ là 0v luôn là thế
sau đây là code: #include <18f4431.h> #device *= 16 ADC = 10 #use delay(clock=4000000) #fuses xt,nowdt #include "hienthiLCD.c" //#use rs232(baud=19200,parity=n,xmit=pin_C6,rcv=pin_C7) #use fast_io(A) #use fast_io(b) #use fast_io(d) #byte porta = 0xF80 #byte portd = 0xF83 Int16 adc ; float a; void ap_suat() { Set_ADC_channel(0) ; Delay_us (10 ); // delay 10 us adc = read_adc ( ) ; a=0.00488*adc; } void main() { set_tris_a(0xff); set_tris_d(0x00); lcd_init(); set_tris_B(0); setup_adc(ADC_CLOCK_INTERNAL ); setup_adc(san0|vss_vdd); While (true ) { ap_suat(); lcd_gotoxy (1,1); printf(lcd_putc,"a: %f",a); if(a>=0.2802) output_high(pin_d0); else { output_low(pin_d0); output_high(pin_d1); } } } |
Múi giờ GMT. Hiện tại là 03:07 PM. |
Tên diễn đàn: vBulletin Version 3.8.11
Được sáng lập bởi Đoàn Hiệp.
Copyright © PIC Vietnam