diference ADC_READ x ADC_GET_SAMPLE

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

diference ADC_READ x ADC_GET_SAMPLE

#1 Post by joseLB » 06 Apr 2015 22:24

Hi
What´s the diference betwen ADC_READ and ADC_GET_SAMPLE + ADC_INIT?

One is faster than other, or more generic?

There is a way to use FOSC/XX instead of internal osc?

Thanks

Jose

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: diference ADC_READ x ADC_GET_SAMPLE

#2 Post by Aleksandar.Mitrovic » 07 Apr 2015 16:30

Hi Jose,

The difference is when you set ADC_Read() he will initialize ADC at the same time. You do not have to use ADC_Init(), he have that function already.
But if you need to read some ADC value many times in a row there is no need to initialize ADC every time.
You will initialize it on start with ADC_Init() and just read values using ADC_Get_Sample() from specific canal.

Yes there is.
Just pick desired MCU in compiler and then press Shift+Ctrl+E.
This will open Edit Project window in which you can chose which oscillator do you want to use in your example, also which clock settings do you need.

Best regards,
Aleksandar

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

Re: diference ADC_READ x ADC_GET_SAMPLE

#3 Post by joseLB » 07 Apr 2015 20:45

Aleksandar.Mitrovic wrote:...Just pick desired MCU in compiler and then press Shift+Ctrl+E.
This will open Edit Project window in which you can chose which oscillator do you want to use in your example, also which clock settings do you need...
Thanks Alexandar.
This is about the ADC converter? I mean, my question is if I can use FOSC/xx for ADC instead of the internal ADC FRC oscilator that ADC_READ sets internaly at each call.
For what I understood from your first explanation, probably ADC_INIT sets ADC to work with the FRC internal oscilator.

But if after ACD_INI, I change ADC oscilator to FOSC/xx (by programing directly ADCON0), later, ADC_GET_SAMPLE will work with that FOSC/xx oscilator, and not with the internal FRC oscilator. That´s it?

Thanks

Jose

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

Re: diference ADC_READ x ADC_GET_SAMPLE

#4 Post by jpc » 08 Apr 2015 08:22

Jose,

using the xtall osc for the ADC is a bit more complicated, you would have to write your own ADC initialisation and probably also the ADC_Get. Look in the datasheet the section on the conversion clock for the details.
Au royaume des aveugles, les borgnes sont rois.

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

Re: diference ADC_READ x ADC_GET_SAMPLE

#5 Post by joseLB » 08 Apr 2015 13:48

Thanks JPC
I´m still trying to use adc routines from Mikroe, but you seems to be right, to do my own routines for a faster and more time controled conversion.
I looked their asm code in a compiled program. Besides other things, they use ANDW for ADCON0 in adc_get_sample, where the oscilator bits are 11, so seems to me that it maintains the ADC at the clock that we set after ADC_INIT, that sets internal RC clock.

Besides that, ADC_init sets some pointes for internal variables where one is the channel among others.

Also I noticed that they have a 22 us delay, in Adc_get_sample before starting the conversion. I´m uncertain the reason for that.

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: diference ADC_READ x ADC_GET_SAMPLE

#6 Post by Aleksandar.Mitrovic » 09 Apr 2015 16:33

Hi,

This delay of 22us will make space for ADC to initialize and prepare for conversion.
For more information please refer to the datasheet of the microcontroller it is probably explained why its necessary.

Best regards,
Aleksandar

joseLB
Posts: 444
Joined: 02 Apr 2006 05:56
Location: Riode Janeiro, Brasil

Re: diference ADC_READ x ADC_GET_SAMPLE

#7 Post by joseLB » 09 Apr 2015 19:03

Thanks Alexandar

Any new I post here!
Jose

Post Reply

Return to “mikroPascal PRO for PIC General”