Hello! Everyone,
I am using PIC18f4550 to port a code written for AVR micro-controller.
So i want to know how fast can i operate PIC18F4550 ADC.
Can i scan and get digital data on 4-channels in 1 ms.
My approach.
Configure ADC -> Enable Interrupt -> Set Channel -> Set GO/Done Bit to Start Conversion -> Do Other Work.
When Conversion Gets Completed, i get interrupt.
Store Converted Values in Buffer and Select New Channel and Start Conversion, if last channel is reached stop further conversion.
Trigger ADC again from channel-0 again after 1 millisecond.
Initialization Part
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| /*
* Configure ADC Here, if necessary
*/
ADCON0bits.ADON = 1; // Power-Up ADC Module
// Set Reference Voltage
ADCON1bits.VCFG1 = 0; // Vss
ADCON1bits.VCFG0 = 0; // Vdd
// Configure ADC Channels
TRISA |= 0x0F; // AN0-AN3 as Input Pins
ADCON1bits.PCFG = 0x0B; // AN0-AN3 Analog Channels
// Clock Configuration
ADCON2bits.ADFM = 1; // Right Justified
ADCON2bits.ACQT = 0x05; // Acquisition Time 12TAD
ADCON2bits.ADCS = 0x06; // Clock Source FOSC/64
Enable_ADC_Interrupt();
// set the first channel to scan
_ADC_Set_Channel(0); |
I started with two channels and and i am getting same data on both channels.
Conversion for channel-0 is proper and for other channel i am getting the same data as of channel-0
Can you please suggest, whats wrong.?
My FOSC = 20MHZ
Clock Source = 1/20 usec = 0.05usec
TAD = 0.05*32 usec = 3.2 usec
Acquisition Time = 12*3.2usec
Please suggest.