Jump to content


omran

Member Since 12 Dec 2014
Offline Last Active Dec 18 2014 07:43 AM
-----

Topics I've Started

ADC at USB HID Custm

13 December 2014 - 06:22 AM

Hi
I am using USB HID Custm from mla
there is one ADC at AN0...I added another one to AN1 I did the needed modification like I put  ADCON1bits.PCFG = 0b1101;
instead of  ADCON1bits.PCFG = 0b1110;
and  TRISAbits.TRISA1 = PIN_INPUT;
and add  a variable case ADC_CHANNEL_1=1; to use it in this way

uint16_t ADC_Read10bit(ADC_CHANNEL channel)
{
    uint16_t result;
    switch(channel)
    {
        case ADC_CHANNEL_0:
            break;
             case ADC_CHANNEL_1:
            break;
        default:
            return 0xFFFF;
    }
    ADCON0bits.CHS = channel;
    ADCON0bits.GO = 1;              // Start AD conversion
    while(ADCON0bits.NOT_DONE);     // Wait for conversion
    result = ADRESH;
    result <<=8;
    result |= ADRESL;
    return result;
}
and did modification in C# then I see that progress bar in the windows form get the value of ADC but actually now both AN0 and AN1 didnt receive the real value ...the number is just between 0 and2
what should I do