Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How fast can i operate PIC184550 ADC?

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
Activity points
10,591
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.
 

You've posted just part of the whole sequence for reading more than one Channel, therefore there may have another reason than just timing sizing ( e.g not properly switching to the 2nd channel ).
 
Hi xpress_embedo,

I would do :
* Set up ADC
* Select channel 0
* Start conversion
* Wait conversion done
* Read value from ADRESH:ADRESL
* Select channel 1
* Start conversion
* Wait conversion done
* Read value from ADRESH:ADRESL
* And so on...

Where is the code for changing channel?
Where is the code to read the result?
Where is the interruption code?

Thoma
 
Thanks for your replies, i figure out what was wrong and corrected it and after this everything is working fine.
I just want to confirm few things.
As per Table 28-29 of PIC Data Sheet.
Minimum ADC Clock is 0.8 u sec and Minimum Acquisition Time Required is 1.4 u sec.

Table.PNG

So as i am operating my device on FOSC = 20MHz
And my ADCON2 register setting is as follow:
Code:
  // Clock Configuration
  ADCON2bits.ADFM   = 1;    // Right Justified
  ADCON2bits.ACQT = 0x01;   // Acquisition Time 2TAD
  ADCON2bits.ADCS = 0x06;   // Clock Source FOSC/64

So my ADC Clock is 20MHz/64 = 312.5 KHz
Which Means 3.2 usec, and it is greater than minimum clock so my system will work properly.
Now coming to Acquisition Time which is 2TAD and 6.4 usec, again which is greater than minimum time specified in datasheet.

Am i calculating everything properly??
The system is working properly just want to confirm whether i understand the things properly or not.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top