PIC32MZ and ADC

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
Bill Legge
Posts: 235
Joined: 28 Oct 2007 03:16
Location: West Australia

PIC32MZ and ADC

#1 Post by Bill Legge » 19 Aug 2020 10:57

Setup is an EasyPIC Fusion v7 board with a PIC32MZ2048EFH144 mcu.
The system clock is at 200MHz with a default peripheral bus at 100MHz.
The aim is to investigate the ADC functions. As I see it the mcu has a total of 6 ADC modules
Class1 - Modules 0,1,2,3,4 that are dedicated to specific pins (AN0/RB0 to Module 0 and so on).
Class2 - Module 7 that may be multiplexed to a variety of pins.
Both produce 12bit results so the maximum is 4095 and 1bit = 3300mV/4095 = 0.806mV so a bit of noise will be produced in your tests.

The first code uses the registers only to configure modules 0,1,2,3,4. No Mikro ADC functions are used.
The code is similar to that published by Microchip:
Section 22. 12-bit High-Speed Successive Approximation
Register (SAR) Analog-to-Digital Converter (ADC)

The ADC process for the 5 channels takes a total of 0.933uS - very fast.
WVL_MZ_ADC_01 download/file.php?mode=view&id=18813

The second lot of code uses only the Mikro ADC functions - and is much simpler!
I presume? it uses module 7 and uses a multiplexer to connect to the different pins?
It takes 10.8uS to process the 5 channels - about 10 time longer.
WVL_MZ_ADC_02:download/file.php?mode=view&id=18813

Although the two projects work OK I'd still welcome any corrections or advice.
Regards Bill Legge in Australia
Attachments
WVL_MZ_ADC_02.7z
(10.18 KiB) Downloaded 98 times
WVL_MZ_ADC_01.7z
(12.3 KiB) Downloaded 169 times

radug
Posts: 117
Joined: 29 Mar 2012 10:21

Re: PIC32MZ and ADC

#2 Post by radug » 20 Aug 2020 09:38

Hello Bill,

> It takes 10.8uS to process the 5 channels - about 10 time longer.
I am by no means a PIC32 expert but I think it may be related to the way the ADC Module is initialized by the MikroC library:
PIC32MZ_ADC.png
PIC32MZ_ADC.png (12.21 KiB) Viewed 1273 times
That's (one of the reasons) why I never use the MikroC libraries.

Best regards,
Radu G.

Bill Legge
Posts: 235
Joined: 28 Oct 2007 03:16
Location: West Australia

Re: PIC32MZ and ADC

#3 Post by Bill Legge » 20 Aug 2020 23:23

I find the Mikro ADC function documentation a bit 'thin.'
For example, the attributes that select the reference voltages
ADC1_Init_Advanced(_ADC_REF_AVDD_AVSS);
Do not appear in the Help file - I had to dig them out of this forum.
And the Mikrochip documentation numbers the ADC modules 0,1,2,3,4 and 7
But, the Mirko ADC_Init only accepts '1' and this is a dedicated ADC module that has a limited number of channels.
So the Mikro module '1' is not the Microchip module '1'
I am guessing that the MX/MZ and latest series of Microchip MCUs are pushing the compiler team.
We should be paying some annual maintenance fee to get better and more frequent updates.
I like MikroElektronika prices but not the lack of updates.

Regards Bill Legge in Australia

takeshikawami@gmail.com
Posts: 4
Joined: 03 Dec 2023 05:43

Re: PIC32MZ and ADC

#4 Post by takeshikawami@gmail.com » 25 Dec 2023 21:26

Hello,
Thank you so much for sharing the resource, it really helps me a lot.
May I ask if you have tried using PIC32MZ to sample in interleaved mode?

Best,
Tracy

Post Reply

Return to “mikroC PRO for PIC32 General”