Page 1 of 2

Analog input not working on PIC32MZ2048ecg100

Posted: Fri Aug 31, 2018 4:33 pm
by stefan.erni
Hi Ben

On the program with a PIC32MZ2048ecg100 a have a little problem.

If I insert potentiometer (slider) and get an int or get a string, the program is frezzing....
I tried AN22 and AN28

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Fri Aug 31, 2018 5:10 pm
by kersing
Simulation or on hardware?

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Fri Aug 31, 2018 5:25 pm
by stefan.erni
on my own hardware

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Fri Nov 09, 2018 9:05 am
by stefan.erni
Hi Ben

I tried potentiometer slider and potentiometer panel. It's compieling and the program is running until I GetString or GetInt. It stops on this command.

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Wed Nov 14, 2018 12:48 pm
by stefan.erni
Hi Ben

The program in the PIC will hang on the part of the Analog Input GetString or GetInt.
where does the problem come from? From the Component or PIC32mz definition?
Or am I doing something wrong?

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Wed Nov 14, 2018 1:49 pm
by Benj
Hello,

Please can you try calling the following ADC functions to help see specifically which call is causing the lock up.

Print LCD ("ADC-")
RawEnable()
Print LCD ("En")
RawSampleInt()
Print LCD ("Int")
RawDisable()
Print LCD ("Dis")

Both the enable and sample functions contain a while loop so I'm guessing one of these is causing the issue.

Attaching a simple program that demonstrates the problem might also be useful so we can look at your configuration settings etc.

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Wed Nov 14, 2018 2:50 pm
by stefan.erni
Hi Ben

Enable/Disable are ok but Rawsample not.
Print LCD ("ADC-")
RawEnable()
OK
Print LCD ("En")
RawSampleInt()
Frezz

Print LCD ("Int")
RawDisable()
Print LCD ("Dis")
OK

I trie to make a small program for the AD and post it

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Wed Nov 14, 2018 3:24 pm
by stefan.erni
Hi Ben

Here the program for the AD Converter.

I need the AN22 on Pin 6 Port C1

Fc8_ecg4matrix_reduced_ad_converter.fcfx
(48.52 KiB) Downloaded 265 times

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Tue Nov 20, 2018 4:20 pm
by stefan.erni
Hi Ben

I tried with FC8.1 but the analog Input is still not working..

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Mon Nov 26, 2018 11:51 am
by stefan.erni
Hi Ben

I found in the PIC32BIT_CAL_ADC.c some infos.
But nothing about the command.
FCD_0d101_Akku1__RawSampleByte();

/* ADC Type 2 Supported Devices ************************************************************
PIC32MZ2048ECG100 Family
*******************************************************************************************/

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Mon Nov 26, 2018 6:21 pm
by Benj
Hello,

You can find the source code for the RawSampleByte function here.

"C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c"

The PIC32MZ2048ecg100 device uses ADC type 2 which starts on line 147.

The CAL file basically defines three functions.

FC_CAL_ADC_Enable
FC_CAL_ADC_Sample
FC_CAL_ADC_Disable

The function FCD_0d101_Akku1__RawSampleByte will be defined in your Flowcode project C file and will directly call the three CAL functions.

If you need me to dig in and try and find the problem then I can do but I may need hardware to do it properly.

Also have you checked the Microchip site, specifically the Errata document for the device to make sure it's not a known silicone problem. If it's a known problem then they will often provide a workaround you can employ.

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Wed Nov 28, 2018 12:41 pm
by stefan.erni
Hi Ben

I looked at the code PIC32BIT_CAL_ADC for a while. There is a line to start the conversation as a comment. How then is the conversion started?

Yes I would like to send you a hardware, but I should have it back at the end of January.

MX_UINT16 FC_CAL_ADC_Sample (MX_UINT8 Sample_Mode)
{
MX_UINT16 iRetVal;

_SFR_WRITE(&AD1CON3,((_SFR_READ(&AD1CON3)&0xBFFFFFFF)|0x40000000));
//AD1CON3bits.GSWTRG = 1;
/* Wait the conversions to complete */
while (_SFR_BIT_READ(&AD1DSTAT1,MX_Current_Channel) == 0);

/* fetch the result */
if (Sample_Mode)
{
iRetVal = _SFR_READ(&AD1DATA0 + MX_Current_Channel);
}
else
iRetVal = (_SFR_READ(&AD1DATA0 + MX_Current_Channel) >> 2); //8-bit ADC

delay_us(1); //Required or processor locks up using Raw functions

return (iRetVal);
}

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Thu Jan 17, 2019 6:03 pm
by stefan.erni
Hi Ben

Can you give me an idea what do to that the analog input is working.
regards

Stefan

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Wed Jan 30, 2019 9:41 am
by stefan.erni
Hi Ben

I suspect the problem is somehow here.....

Code: Select all

_SFR_WRITE(&AD1CON3,((_SFR_READ(&AD1CON3)&0xBFFFFFFF)|0x40000000));
 //AD1CON3bits.GSWTRG = 1;
 /* Wait the conversions to complete */
 while (_SFR_BIT_READ(&AD1DSTAT1,MX_Current_Channel) == 0);

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Wed Jan 30, 2019 6:55 pm
by Benj
Hello,

Sorry for the delay. Let me see if I can replicate the problem here for you and see if I can get it working.

I'll bring my PIC32MZ board in tomorrow.

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Thu Feb 07, 2019 5:06 pm
by Benj
Hello,

Right I'm testing the ADC on the PIC32MZ2048EFG100 and this is not hanging but doesn't seem to be giving me the correct value at the moment.

I'll investigate and see if I can get this working and then compare with the ECG device.

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Wed Feb 27, 2019 2:22 pm
by stefan.erni
Hi Ben

This old ECG Type PIC PIC32MZ2048ECG is on the old chipKIT Wi-FIRE! Revision B

https://reference.digilentinc.com/chipk ... 1507019925

The newer EFG Type PIC32MZ2048EFG100 microcontroller is on the newer chipKIT Wi-FIRE

https://store.digilentinc.com/wi-fire-w ... ler-board/

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Wed Feb 27, 2019 5:30 pm
by Benj
I do happen to have a ChipKit WiFire board here in my collection but it's the newer version :( Same as the board you sent.

I got excited for a minute there :roll:

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Fri Mar 29, 2019 11:22 am
by stefan.erni
Hi Ben

How is the AD with the PIC32MZ2048efg going on?
Maybe with the PIC32MZ2048ecg it will not work.

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Wed Aug 07, 2019 2:21 pm
by stefan.erni
Hi Ben

Now Im using the newer PIC32MZ2048efg100

If I use the analog input its not crashing but it don't give me a correct value back.
I put 2.2 volt on the input and it shows like 0.00324 but sometimes a little more or less.
If I remove the 2.2volt it's always shows the same values..
The progam use the AN22. I config to AN21 and AN23 but the same value even there is no 2.2volt

regards

Stefan

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Fri Aug 23, 2019 8:03 am
by stefan.erni
Hi Ben

You wrote me a while ago about the AD from the PIC. Is there a way to fix it?
regards

Stefan
Right I'm testing the ADC on the PIC32MZ2048EFG100 and this is not hanging but doesn't seem to be giving me the correct value at the moment.

I'll investigate and see if I can get this working and then compare with the ECG device.

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Thu Dec 05, 2019 11:48 am
by stefan.erni
Hi Ben

I use a simple programloop to test the AD converter in the PIC Pin6 AN22.
I send the result to the Computer. It shows just numbers like 1,2,0,1,0,1
On the hardwarepin it's the correct voltage of 1.9Volt.(litium akku divided by 2)
There is a problem somewhere ...
Analog-input.PNG
(15.32 KiB) Downloaded 1352 times

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Thu Feb 27, 2020 6:55 pm
by stefan.erni
Hi Ben

I found a problem.
If I use the slider_plastic component and choose AN0 (port B0) the AD is working fine with the signal on B0.

When I change the slider_plastic component to:
AN1 (port B1) the AD is showing me the signal on B0.
AN22 (port C1) the AD is showing me the signal on B0.
I'ts shows always the signal on AN0 (port B0)

regards

Stefan

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Fri Feb 28, 2020 11:50 am
by Benj
Hi Stefan,

Thanks for letting us know. I've pushed a change that hopefully will make a difference. If not then let me know and I'll investigate further for you.

Re: Analog input not working on PIC32MZ2048ecg100

Posted: Fri Feb 28, 2020 2:22 pm
by stefan.erni
Hi Ben

It's still the same. No change.