PIC 24FJ64GA002 problem a AD prevodnikom

Prisiel som na to.

Moj kod:

[code]#include “config_diall.h” // http://www.diallix.net/headers
#include “config_words.h” // http://www.diallix.net/headers
#include “LCD_D.h” // http://www.diallix.net/el/145-lcdcontroll
char *PageSys(void)
{
return “0x21”;
}
struct attribute ((packed)) {
float voltage;
float number;
char results_voltage[32];
char results_number[32];
unsigned long ADCValue1, ADCValue2;
}ADC_Results;

void ADC_Init(void)
{
ADC_Results.ADCValue1=0;
ADC_Results.ADCValue2=0;
CLKDIV = 0;
//Init_Port2(&PORTA, 0, “analog”); /* Set AN0 as analog /
//Init_Port2(&PORTA, 1, “analog”); /
Set AN1 as analog /
AD_Set_Analog(AN0); /
Set AN0 as analog /
AD_Set_Analog(AN1); /
Set AN1 as analog /
Set_ADC_port(AN0); /
Set AN0 as input /
Set_ADC_port(AN1); /
Set AN1 as input /
Scan_ADC_port(AN0); /
Set AN0 for scanning /
Scan_ADC_port(AN1); /
Set AN1 for scanning /
//Config_OUT(TRISA,0); /
Set RA0 for detect LED /
T3CON=0b1000000000110000; /
50msec, 1/256,FOSC=16MH, Current time clock /
PR3 = 3124; /
50000 ·((1/16) —256)-1 = 3124 /
AD1CON1 = 0x8044; /
AD1CON1:A/D1 Configure sample clock source
and conversion trigger mode.
Unsigned Fraction format (FORM<1:0>=10),
Manual conversion trigger (SSRC<3:0>=000),
Manual start of sampling (ASAM=0),
No operation in Idle mode (ADSIDL=1) /
AD1CON2 = 0x0400; /
AD1CON2:A/D2; 31Tad 3.0Tcy
Configure A/D voltage reference
and buffer fill modes.Vr+ and Vr- from
AVdd and AVss (VCFG<2:0>=000),
Inputs are not scanned,
Interrupt after every sample /
AD1CON3 = 0x0000; /
AD1CON3:A/D3; MUX A
Configure A/D conversion clock as Tcy/2 /
AD1CHS = 0x0000; /
AD1CHS:A/D
Configure input channels /
//AD1CON2bits.CSCNA = 1; /
Scan inputs /
AD1CON2bits.SMPI0 = 1; /
Interrupt after 2 sequences /
//AD1CSSLbits.CSSL0 = 1; /
Scan 2 channels /
IEC0bits.AD1IE = 1; /
Enable A/D conversion interrupt /
AD1CON1bits.ADON = 1; /
Turn on A/D /
AD1CON1bits.ASAM = 1; /
Sampling begins immediately after the last conversion /
AD1CON1bits.SAMP = 1; /
Start sampling the input */
}

int main(void)
{
ADC_Init();
Display_Init();
Delay_us(50);
while(1)
{
}
return 0;
}
void attribute((interrupt,auto_psv)) _ADC1Interrupt(void) /* interrupt thread /
{
AD1CON1bits.ASAM = 1; // Start automatic sampling and conversion
while (IFS0bits.AD1IF == 0);
ADC_Results.ADCValue1 = ADC1BUF0; /
Get data from buffer0 /
ADC_Results.ADCValue2 = ADC1BUF1; /
Get data from buffer1 /
IFS0bits.AD1IF = 0; /
ADC flag set 0 */
}[/code]

Pre cely kod s displajom navstivte moj web “http://www.diallix.net/el/200-adc-we-display-the-voltages-of-two-channels-on-the-lcd