Possible bug in ADC of dsPIC30F6010A

Post Reply
NigmaTech
Posts: 23
Joined: Wed May 21, 2008 11:53 am

Possible bug in ADC of dsPIC30F6010A

Post by NigmaTech » Sat May 31, 2008 7:01 pm

Hi Lubin!

Could You check connections of pin AN7 and AN3 in your blockset? It's very strange, but when I want to convert AN7 analog input, dsPIC is converting different value than it's real. I checked all connections in my PCB and that value is on pin AN3. Is this possible, AN3 and AN7 are changed places?

Blockset version 0.98

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Possible bug in ADC of dsPIC30F6010A

Post by LubinKerhuel » Sat May 31, 2008 9:14 pm

Hi Nigma,

This would be quite surpising to have an inversion on pin AN7 ==> AN3.
Could you upload the model (.mdl file) so as to have a look ?
What are the parameters for Vref+ and Vref- ?

Lubin

NigmaTech
Posts: 23
Joined: Wed May 21, 2008 11:53 am

Re: Possible bug in ADC of dsPIC30F6010A

Post by NigmaTech » Sat May 31, 2008 9:42 pm

I used AVdd - AVss.
Attachments
Gyro_test.mdl
(27.44 KiB) Downloaded 165 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Possible bug in ADC of dsPIC30F6010A

Post by LubinKerhuel » Sun Jun 01, 2008 11:06 pm

The generated code for the configuration of the ADC with your model is :

Code: Select all

  124     /* S-Function "dsPIC_ADC" initialization Block: <Root>/ADC Input */
  125     /* Initialise ADC converter */
  126     /* 0 mean each 1 conversion */
  127   #define NoSamplesADC                   1
  128   #define ADCSval                        3
  129   #define SAMCval                        (1 << 8)
  130   #define OutFormatBitsval               (0 << 8)
  131   #define VoltRef                        (0 << 13)
  132   
  133     
  134     ADCON1 = 0x00E4 | (0 << 10)| OutFormatBitsval;
  135     ADCON2 = 0x0400 | (NoSamplesADC << 2) | VoltRef;
  136     ADCSSL = 144;
  137     ADCON3 = (ADCSval | SAMCval) & 0xff7f;
  138     ADCHS = 0x0000;
  139     IPC2 = (IPC2 | (6 << 12));           /*Interrupt Priority : 6*/
  140     _ADIF = 0;
  141   
  142  
  143   
  144   
  145     /* Turn on ADC Module */
  146     ADCON1bits.ADON= 1;
To read the converted values, the code is :

Code: Select all

   39       /* S-Function "ADC" Block: <Root>/ADC Input */
   40       Gyro_test_B.ADCInput_o1 = ADCBUF0;
   41       Gyro_test_B.ADCInput_o2 = ADCBUF1;
If there is something wrong with that, I would be glad to correct it.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest