Truyền ADC 8 KÊNH
Tôi có đoạn code này nhưng nó chỉ truyền lên vb kênh 0 mà thôi ,xin góp ý giúp với .thank
#include <C:\Program Files\PICC\Devices\16F877A.h>
#device *=16 ADC=8
#fuses HS,NOWDT,NOLVP,NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
byte adc;
byte buffer;
#INT_TIMER0
void send_data()
{
byte begin = 0xAA;
adc = read_adc();
putc(begin);
putc(adc);
}
void main()
{
int channel;
setup_adc_ports( ALL_ANALOG );
setup_adc(ADC_CLOCK_INTERNAL );
for (channel=0;channel<=7;channel++)
{
set_adc_channel( channel );
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2);//sets the internal clock as source
enable_interrupts(GLOBAL);
enable_interrupts(INT_TIMER0); // ngat timer0 de update screen
send_data();
while(1)
{
buffer=getc();
}
}
}
|