Skip to main content

Show Posts

This section allows you to view all Show Posts made by this member. Note that you can only see Show Posts made in areas you currently have access to.

Messages - thefrontline

1
Web platform / Analog Input
I am trying to use AN2 and AN3 on this board as analog inputs (PGC & PGD). I am having trouble getting the board to read the correct values, I've tried 10-bit and 12-bit modes. The only values I've got out of ADC1BUF0 are 0 and 32767, both times when I have read those values I had no inputs on the pins. If I must use a negative reference to use these pins I would like to use AN0 or AN1 which are unused and right beside them, I've bascially tried everything and have read the manual, but can't figure out how to get these analog inputs to work. Could anyone give me some direction or code? Here is what I have now in the InitHardware function:

       AD1PCFGL = 0xFFFF; //digital pins
   AD1PCFGLbits.PCFG2 = 0;
   AD1PCFGLbits.PCFG3 = 0;
   
   AD1CON1bits.FORM   = 3;      // Data Output Format: Signed Fraction (Q15 format)
   AD1CON1bits.SSRC   = 2;      // Sample Clock Source: GP Timer starts conversion
   AD1CON1bits.ASAM   = 1;      // ADC Sample Control: Sampling begins immediately after conversion
   AD1CON1bits.AD12B  = 0;      // 12-bit ADC operation turned off
   
   AD1CON3bits.ADRC = 0;      // ADC Clock is derived from Systems Clock
   AD1CON3bits.ADCS = 63;   
   AD1CON2bits.CHPS  = 1;      // Converts CH0
   
    //AD1CHS0bits.CH0SA=2;      // MUXA +ve input selection (AN5) for CH0
   AD1CHS0bits.CH0NA=0;      // MUXA -ve input selection (Vref-) for CH0

   IFS0bits.AD1IF = 0;         // Clear the A/D interrupt flag bit
        IEC0bits.AD1IE = 0;         // Do Not Enable A/D interrupt
   AD1CON1bits.ADON = 1;

Thanks in advance.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01242249592session_write_close ( )...(null):0
20.01272381168ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01272381944Database_MySQL->query( ).../DatabaseHandler.php:119
40.05712520656Database_MySQL->error( ).../Db-mysql.class.php:273