Hi epilot,

you piqued my curiosity re. using vref to offset the ADC. Its limited by the requirment that Vref+ min is 2volts. Using a voltage divider 10k to gnd and 15k to Vdd (5volts). Pin 5 (AN3) goes to the divider. The only software change is to add ADCON1 = %00000001 after ADCON0 is set (note the missing binary sign - by shear luck in this case it works without the %) That gets you 2.5 gain - if my maths is right, which would be unusual because I'm rubbish at maths.

The other way to get more gain is to multiply CANAL by some constant

Code:
BARRA:
IF MARCA1 = 1 THEN                            'Si es verdadero
LINEA = $2
ADCIN 7, CANAL
CANAL = CANAL * 4
MARCA1 = 0                                    '1ºLinea LCD, muestra canal L
ELSE                                          'Si no lo es
LINEA = $c0
ADCIN 6, CANAL
CANAL = CANAL * 4
MARCA1 = 1                                    '2ºLinea LCD, muestra canal R
ENDIF
Now you can adjust the gain on the fly by detecting when it clips and changing constant to a variable. I think I may have suggested in an earlier post that you should divide the ADC output, D'oh (spelling according to Wiki). I think you'll still need some gain on the input.

Hey, I just realised, the ADC in a 877a is 10 bits but CANAL is only a byte, it's throwing away 2 msb's.

George


George