PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 04, 2006 3:13 pm |
|
|
I don't have vs. 2.707. The closest I have is vs. 2.705. I made the
test program shown below and looked at the .LST file. The A/D
functions appear to produce the correct ASM code. This test program
is only for 8-bit A/D output, but it does show how to switch channels.
Try doing a simple program like this one, to see if you can get it
working with two A/D channels.
Code: |
#include <16C771.h>
#fuses XT,NOWDT,PUT,BROWNOUT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_B1, rcv=PIN_B0)
#bit ADFM_BIT = 0x9F.7
void main()
{
int result_0;
int result_1;
setup_adc_ports(sAN0 | sAN1 | VSS_VDD);
setup_adc(ADC_CLOCK_DIV_64);
ADFM_BIT = 1; // Right justify the result
while(TRUE)
{
set_adc_channel(0);
delay_us(20);
result_0 = read_adc();
set_adc_channel(1);
delay_us(20);
result_1 = read_adc();
printf("result 0 = %x\n\r", result_0);
printf("result 1 = %x\n\r", result_1);
}
} |
|
|