CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Why setup_adc perform an ADC conversion?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

Why setup_adc perform an ADC conversion?
PostPosted: Wed Jun 01, 2016 12:00 pm     Reply with quote

I was stepping line by line and when I get to the following line


Code:
SETUP_ADC(ADC_CLOCK_DIV_4|ADC_TAD_MUL_4);


the cursor doesn't move, so I go to the dissasembly list and see that is waiting to the ADC to finish a conversion initiated by the same command. WTF? Shocked

It is a bug or I forgot to indicate something to the precompiler?

If I make a setup I want to setup the ADC not start a conversion.
There's a way to get what I want or should I use ASM?
_________________
Electric Blue
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jun 01, 2016 12:59 pm     Reply with quote

Have to say the obvious...
Which PIC
What Compiler and version
Please post small compilable program that shows this.
When you post program, also post the listing.

Thanks

Jay
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Wed Jun 01, 2016 2:11 pm     Reply with quote

The PIC is a PIC18F67J50, V5.058; I didn't think that this matters for so simple line of code.

I didn't post the code since is part of the copyright of CCS code.

Code:
7730:                    SETUP_ADC(ADC_CLOCK_DIV_2|ADC_TAD_MUL_2);
 0FCAC    50C1     MOVF 0xfc1, W, ACCESS
 0FCAE    0BC0     ANDLW 0xc0
 0FCB0    0908     IORLW 0x8
 0FCB2    6EC1     MOVWF 0xfc1, ACCESS
 0FCB4    8EC1     BSF 0xfc1, 0x7, ACCESS
 0FCB6    80C2     BSF 0xfc2, 0, ACCESS
 0FCB8    8CC1     BSF 0xfc1, 0x6, ACCESS
 0FCBA    82C2     BSF 0xfc2, 0x1, ACCESS
 0FCBC    B2C2     BTFSC 0xfc2, 0x1, ACCESS
 0FCBE    D7FE     BRA 0xfcbc
 0FCC0    9CC1     BCF 0xfc1, 0x6, ACCESS

_________________
Electric Blue
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 01, 2016 4:53 pm     Reply with quote

Compile it with the .LST file in Symbolic mode. Now what's it doing ?
Quote:
..... SETUP_ADC(ADC_CLOCK_DIV_2 | ADC_TAD_MUL_2);
0001E: MOVF ANCON0,W
00020: ANDLW C0
00022: IORLW 08
00024: MOVWF ANCON0
00026: BCF ANCON0.ADFM
00028: BSF ANCON1.ADON
0002A: BSF ANCON0.ADCAL
0002C: BSF ANCON1.NOT_DONE
0002E: BTFSC ANCON1.NOT_DONE
00030: BRA 002E
00032: BCF ANCON0.ADCAL

Check the PIC data sheet in the A/D section for more info on calibration.
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Thu Jun 02, 2016 10:01 am     Reply with quote

I can't configure MPLAB IDE v8.80 in order to show the bits names, but yes, now I can see that is not a regular conversion.

Unfortunately there's no way to disable this.

I will make some changes in my code to not setup the ADC every time that I need a conversion.

Thanks for your answer.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Fri Jun 03, 2016 1:44 am     Reply with quote

Why do you not want the auto-calibration?.

The data sheet says:
"it should be performed after each
device Reset or if there are other major changes in
operating conditions.".
'Should'......

Understand that the calibration does _not_ read a channel. It is a dummy read to get the offsets internal to the chip.

Now CCS are triggering this to happen here, since otherwise it'll happen the next time you try to read the chip.

You can trigger it yourself later, if (for instance) the actual voltages around the chip have not settled at this time, by setting the ADCAL bit and performing another dummy read.

If you don't use this, the ADC is not guaranteed to meet it's specified accuracies. Quite a few other chips with similar ADC's have huge errata, about very large offset numbers sometimes occurring. This is MicroChip's solution to this....

So, why do you want to get rid of it?.

If this is just for debugging, then add a rule to the stimulus settings to make the ADC complete a conversion.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group