FORUM TOPIC · READ ONLY
Possible bug in ADC of dsPIC30F6010A
Possible bug in ADC of dsPIC30F6010A
Forum : bug reports
4 message(s) · archive en lecture seule
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
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
Re: Possible bug in ADC of dsPIC30F6010A
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
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
Re: Possible bug in ADC of dsPIC30F6010A
I used AVdd - AVss.
Re: Possible bug in ADC of dsPIC30F6010A
The generated code for the configuration of the ADC with your model is :
To read the converted values, the code is :
If there is something wrong with that, I would be glad to correct it.
<i>
</i> 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 :
<i>
</i> 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.