• AVR Freaks

Harmony - ADC setup in the Configurator for Automatic Channel Scan mode Framework 1.06.02

Author
Don2
Senior Member
  • Total Posts : 72
  • Reward points : 0
  • Joined: 2015/03/09 13:29:51
  • Location: 0
  • Status: offline
2016/03/01 17:39:36 (permalink)
0

Harmony - ADC setup in the Configurator for Automatic Channel Scan mode Framework 1.06.02

I am trying to use the Configurator to setup automatically scanning ADC channels 2-15.  Has anyone been able to do this? I can do this on my board using MLA, but not Harmony.  So, I know the hardware is fine.  I find that after I set up the Configurator, and use DRV_ADC_Initialize(), DRV_ADC_Start() and DRV_ADC_Open() that the CSCNA bit is never set.   When I stop the program and manually set this bit to enable the ADCs, I get high readings that indicating that the ADC pins are not set for Analog, but it looks like they are set right.  There does not seem to be any guidance on the Configurator for ADCs, in fact I had to do some hacking to find I needed to include drv_adc_static.h in my file.  To figure out what is going on with the Configurator settings, I using the 61104E.pdf (Chapter 17) as a guide, stopping the program, and examining the peripherals as shown in Windows|PCMemeryViews|Peripherals display.  I am to the point where I am ready to forget the Configurator and just manual set it up unless someone has already figured this out.
#1
Don2
Senior Member
  • Total Posts : 72
  • Reward points : 0
  • Joined: 2015/03/09 13:29:51
  • Location: 0
  • Status: offline
Re: Harmony - ADC setup in the Configurator for Automatic Channel Scan mode Framework 1.0 2016/03/02 08:19:04 (permalink)
0
OK. I got it running.  Here are some pointers for anyone trying to use the Configurator to set up ADC scanning.
1. I needed to include drv_adc_static.h (not drv_adc.h) in the app.c file.
2. I had to set the ADC pins to scan manually by adding the statement "AD1CSSLSET = 0x0000FFFC;" in the initialization.   I did not want to scan AN0 or AN1 which is why the last digits is C instead of F.
2. I did use  DRV_ADC_Initialize(), DRV_ADC_Start() and DRV_ADC_Open(), but it did not start the scanning, so to enable the scanning, I had to set the CCNA bit manually, by using "AD1CON2bits.CSCNA = 1" 
 
I hope this will help someone else.
#2
anthony_1234
Junior Member
  • Total Posts : 67
  • Reward points : 0
  • Joined: 2015/09/11 14:20:13
  • Location: 0
  • Status: offline
Re: Harmony - ADC setup in the Configurator for Automatic Channel Scan mode Framework 1.0 2016/03/02 08:56:35 (permalink)
0
Hi Don,
 
There example in harmony that use scan, you should not need to access register directly.  Could you provide the specific PIC32 that you are using. 
post edited by anthony_1234 - 2016/03/02 08:58:44
#3
Don2
Senior Member
  • Total Posts : 72
  • Reward points : 0
  • Joined: 2015/03/09 13:29:51
  • Location: 0
  • Status: offline
Re: Harmony - ADC setup in the Configurator for Automatic Channel Scan mode Framework 1.0 2016/03/02 12:11:47 (permalink)
0
PIC32MX795F512L.
I did not see an example of using the Configurator to set up ADCs.  I did see one example for a single ADC for Temp, but I did not try it to see if it worked or not.  I was more interested in using the Configurator to set up multiple automatic scanning ADCs thinking it would be quicker. I think the Temp example uses drv_adc.h, but the Configurator expects drv_adc_static.h.   Next time I may skip the Configurator and go right to looking at the data sheet and setting the Config Registers directly.  In this case it would have saved me a couple of days work (no exaggeration here).  The Configurator would be much improved if it showed the Config Registers as you selected settings so you can verify what you are doing.
 
Let me know if you find a way using the Configurator and DRV_ADC_Initialize(), DRV_ADC_Start() and DRV_ADC_Open() to set the AD1CON2bits.CSCNA with out using "AD1CON2bits.CSCNA = 1"  in the code.
 
 
#4
MariuszS
New Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2015/07/23 11:15:16
  • Location: Poland
  • Status: offline
Re: Harmony - ADC setup in the Configurator for Automatic Channel Scan mode Framework 1.0 2016/10/17 13:21:39 (permalink)
0
Hello all.
I would like use harmony configurator 1.8XXX. for DRV_ADC. PIC32MX695F512H 
Documentation *.chm about using this, are absolute fake. some function are missing or with errors. not usable.
I need get ADC sample from only one input (an3) by software sample  one time per 100ms, and i can't do this !!!!
DRV_ADC_SamplesAvailable() return that sample are available (but no change any time) or never available ( i tried different configuration)
please let me know ho i can use DRV_ADC for software sampling on demand.....
Within fake documentation it will be done :
DRV_ADC_OPEN->DRV_ADC_START->DRV_ADC_SamplesAvailable->DRV_ADC_READ and go to DRV_ADC_START.....
 
regards Mariusz 
 
 
#5
Don2
Senior Member
  • Total Posts : 72
  • Reward points : 0
  • Joined: 2015/03/09 13:29:51
  • Location: 0
  • Status: offline
Re: Harmony - ADC setup in the Configurator for Automatic Channel Scan mode Framework 1.0 2016/10/18 07:02:05 (permalink)
0
I feel you pain, what a programmer needs to do to get something running in Harmony is almost non-existent. There is a lot of info on what the Configurator adds, but very little clear info on what you, the programmer, needs to add to make it work.   Here is how I figured it out for my application, and it is also a general way to figure out what the Configurator is setting up.
1.Change and generator your setting from the Configurator.
2. Compile and run the program under debug
3. pause the program.  
4. Then open the Peripherals screen by selecting from the IDE menu Window>Pic Memory Views>Peripherals.  This will show the registers that get set up by the Configurator.
5. Look in the datasheet so you can search for the appropriate Registers.  Keep in mind that the names in the Configurator, datasheet, and the peripheral display may have slightly different names, but easy to correlate. 
 
Another big point that got me in the beginning is that the ADC result is put into the first location of the ADC pointer, not in the location corresponding  to the ADC number.  So, if you have only one ADC and it is ADC3, then the value will be in the buffer at 0 offset.  If you use ADC3, ADC5, and ADC7, then the results will be in the buffer location 0, 1, and 2.
Don
#6
RISC
Super Member
  • Total Posts : 5376
  • Reward points : 0
  • Status: offline
Re: Harmony - ADC setup in the Configurator for Automatic Channel Scan mode Framework 1.0 2016/10/18 15:41:32 (permalink)
0
Hi,
 
Did you try the examples for PIC32MX795 & ADC which are in this directory :
c:\microchip\harmony\v2_01b\apps\examples\peripheral\
(should be almost the same if you use an older Harmony version)
 
Regards
 
#7
Jump to:
© 2019 APG vNext Commercial Version 4.5