How do you calculate the sampling rate for a SAR ADC on PIC16F MCU?

The sampling time for devices like the PIC16F18325/45, which utilizes a successive approximation register (SAR) ADC, is not specified in the datasheet. There are a lot of dependencies that affect the sampling rate, so it is hard to specify. For an approximate best case of the sampling rate, this formula can be used:

Sample Rate = (TAD x 12) +TACQ + (Number of instruction cycles to read the ADRES registers and write to memory).

There are a number of dependencies for each variable:

• TAD (Period of A/D Conversion) - times depend on the ADCS bits and the device frequency. You would need to calculate the TAD based on your settings.
• TACQ (Period of A/D acquisition time) - times are dependent on temperature and external impedance. You would use your nominal operating temperature, and approximate the external impedance to the channel.

The number of instruction cycles is dependent on whether or not an interrupt is used, how the ADRES register reading is handled, and how the data is stored.

If ADC interrupts are used, the cycle times would increase due to the interrupt vectoring, and there is only an estimate of how many instructions it takes to jump to the vector (typically from two to five instructions). If the code reads the ADRES registers, then saves the value in RAM, that will take fewer instructions compared to writing the values to EEPROM or Flash.

Finally, each ADC channel does not have a specified sampling rate. For example, based on the information above, if channel X has an impedance of 200 Ω, while channel Y has 2 kΩ, channel X would likely have a faster rate since it takes a little less time for the sample and hold capacitor to charge. Another thing to consider is whether or not the ADC is kept on the whole time during operation, or if the ADC is turned off between acquisitions, and how often the application will switch to a new channel.

To summarize, there isn't a sampling rate specification for this ADC. A fair approximation can be made using the information above, but it is not a guaranteed rate.