Skip to main content
added 21 characters in body
Source Link
iggy
  • 698
  • 3
  • 5

Do you use DMA?

You are reading ADCBUF0 all the time.

I think some dsPICs have dedicated ADCBUFx for every analog pin, others just use ADCBUF0 for every conversion.

You also need to configure other stuff...

Tell adc to scan channels:

AD1CON2bits.CSCNA=1; //SCAN INPUTS FOR CH0+

Tell adc to convert for instance CH0:

AD1CON2bits.CHPS=0; //CONVERT CH0

Select which channels to scan:

  • AD1CSSH
  • AD1CSSL

The analog channels and if you have two ADCs on board both configuration must be identical for registers:

  • AD1PCFGH
  • AD1PCFGL
  • AD2PCFGH
  • AD2PCFGL

The dsPIC ADC can be a pain to configure.

Do you use DMA?

You are reading ADCBUF0 all the time.

I think some dsPICs have dedicated ADCBUFx for every analog pin, others just use ADCBUF0.

You also need to configure other stuff...

Tell adc to scan channels:

AD1CON2bits.CSCNA=1; //SCAN INPUTS FOR CH0+

Tell adc to convert for instance CH0:

AD1CON2bits.CHPS=0; //CONVERT CH0

Select which channels to scan:

  • AD1CSSH
  • AD1CSSL

The analog channels and if you have two ADCs on board both configuration must be identical for registers:

  • AD1PCFGH
  • AD1PCFGL
  • AD2PCFGH
  • AD2PCFGL

The dsPIC ADC can be a pain to configure.

Do you use DMA?

You are reading ADCBUF0 all the time.

I think some dsPICs have dedicated ADCBUFx for every analog pin, others just use ADCBUF0 for every conversion.

You also need to configure other stuff...

Tell adc to scan channels:

AD1CON2bits.CSCNA=1; //SCAN INPUTS FOR CH0+

Tell adc to convert for instance CH0:

AD1CON2bits.CHPS=0; //CONVERT CH0

Select which channels to scan:

  • AD1CSSH
  • AD1CSSL

The analog channels and if you have two ADCs on board both configuration must be identical for registers:

  • AD1PCFGH
  • AD1PCFGL
  • AD2PCFGH
  • AD2PCFGL

The dsPIC ADC can be a pain to configure.

Source Link
iggy
  • 698
  • 3
  • 5

Do you use DMA?

You are reading ADCBUF0 all the time.

I think some dsPICs have dedicated ADCBUFx for every analog pin, others just use ADCBUF0.

You also need to configure other stuff...

Tell adc to scan channels:

AD1CON2bits.CSCNA=1; //SCAN INPUTS FOR CH0+

Tell adc to convert for instance CH0:

AD1CON2bits.CHPS=0; //CONVERT CH0

Select which channels to scan:

  • AD1CSSH
  • AD1CSSL

The analog channels and if you have two ADCs on board both configuration must be identical for registers:

  • AD1PCFGH
  • AD1PCFGL
  • AD2PCFGH
  • AD2PCFGL

The dsPIC ADC can be a pain to configure.