I don't know about TAD. Please explain it clearly. I am using ext hs osc 20 Mhz. I am trying to implement adc routine in asm and I want to know every detail about adc.
https://ww1.microchip.com/downloads/en/devicedoc/39755a.pdf Page 229
My Fosc is 20 MHz
Tad = x/Fosc where x = 2, 4, 8, 16, 32, or 64
if x = 2, Tad = 0.1us
x = 4, Tad = 0.2us
x = 8. Tad = 0.4us
x = 16, Tad = 0.8us
x = 32, Tad = 1.6us
x = 64. Tad = 3.2us
Tcy = 1/Fosc = 1/20 MHz = 0.05us = 50ns
Tosc is 1/(Fosc/4) = 1(20 MHz/4) = 1/5 MHz = 0.2us
The datasheet says, assuming minimum Tad = 0.8us, for 20 MHz Fosc, Tosc = 16Tosc
16Tosc = 16 * 0.2us = 3.2us.
Tacq = 2.96us mentioned in
http://ww1.microchip.com/downloads/en/devicedoc/39755a.pdf page 232 last part
Am I right?
Just give me an example for 20 MHz Fosc. What should be the value of ADCON2? I'm using PIC18F4523, 12-bit ADC.
What should be ACQT2-ACQT0 and ADCS2-ADCS0?
All I know is this,
The following steps should be followed to perform an A/D
1. Configure the A/D module:
• Configure analog pins, voltage reference and
digital I/O (ADCON1)
• Select A/D input channel (ADCON0)
• Select A/D acquisition time (ADCON2)
• Select A/D conversion clock (ADCON2)
• Turn on the A/D module (ADCON0)
2. Configure the A/D interrupt (if desired):
• Clear ADIF bit
• Set ADIE bit
• Set GIE bit
3. Wait the required acquisition time (if required).
4. Start conversion by setting the GO/DONE bit
(ADCON0<1>).
5. Wait for the A/D conversion to complete by either:
• Polling for the GO/DONE bit to be cleared
OR
• Waiting for the A/D interrupt
6. Read the A/D Result registers (ADRESH:ADRESL)
and clear the ADIF bit, if required.
7. For the next conversion, go to step 1 or step 2,
as required.
The A/D conversion time per bit is defined as
TAD. A minimum wait of 2 TAD is required before
the next acquisition starts.
but I need some help in implementing adc routine in asm.