Analog input not working on PIC32MZ2048ecg100
Moderator: Benj
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Analog input not working on PIC32MZ2048ecg100
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
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
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
Simulation or on hardware?
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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.
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.
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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?
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?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
Hi Ben
Enable/Disable are ok but Rawsample not.
I trie to make a small program for the AD and post it
Enable/Disable are ok but Rawsample not.
OKPrint LCD ("ADC-")
RawEnable()
FrezzPrint LCD ("En")
RawSampleInt()
OKPrint LCD ("Int")
RawDisable()
Print LCD ("Dis")
I trie to make a small program for the AD and post it
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
Hi Ben
Here the program for the AD Converter.
I need the AN22 on Pin 6 Port C1
Here the program for the AD Converter.
I need the AN22 on Pin 6 Port C1
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
Hi Ben
I tried with FC8.1 but the analog Input is still not working..
I tried with FC8.1 but the analog Input is still not working..
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
Hi Ben
I found in the PIC32BIT_CAL_ADC.c some infos.
But nothing about the command.
FCD_0d101_Akku1__RawSampleByte();
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
*******************************************************************************************/
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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.
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);
}
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
Hi Ben
Can you give me an idea what do to that the analog input is working.
regards
Stefan
Can you give me an idea what do to that the analog input is working.
regards
Stefan
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
Hi Ben
I suspect the problem is somehow here.....
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);
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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/
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/
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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
I got excited for a minute there
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
Hi Ben
How is the AD with the PIC32MZ2048efg going on?
Maybe with the PIC32MZ2048ecg it will not work.
How is the AD with the PIC32MZ2048efg going on?
Maybe with the PIC32MZ2048ecg it will not work.
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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
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
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
Hi Ben
You wrote me a while ago about the AD from the PIC. Is there a way to fix it?
regards
Stefan
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.
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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 ...
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 ...
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Analog input not working on PIC32MZ2048ecg100
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact: