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
diference ADC_READ x ADC_GET_SAMPLE
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: diference ADC_READ x ADC_GET_SAMPLE
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
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
Re: diference ADC_READ x ADC_GET_SAMPLE
Thanks Alexandar.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...
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
Re: diference ADC_READ x ADC_GET_SAMPLE
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.
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.
Re: diference ADC_READ x ADC_GET_SAMPLE
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.
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.
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: diference ADC_READ x ADC_GET_SAMPLE
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
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
Re: diference ADC_READ x ADC_GET_SAMPLE
Thanks Alexandar
Any new I post here!
Jose
Any new I post here!
Jose