I am using a PIC18F25Q10-I/SP MCU in one of my designs and one of its main function is to read a changing value of 0-5v coming from an inverting Op-Amp.
the input is tested before with a different MCU and is working properly but when it's connected to the bespoke MCU it malfunctions and gets stuck at 5v DC andthe MCU would Reset if we short any signal to the A/D pin (e.g. trying to touch the pin with 5v signal).
I am not sure but i am assuming this is a software issue, am I right with this? has anyone came across something similar?
some issues:
* driving VRef from a 2.5KOhms source is rather optimistc.
* driving VRef without a capacitor to GND is a non go ( for me)
* driving Vref from another 5V source than the microcontroller supply needs careful power sequencing, else you violate input voltage range
* ADC input from another source than the microcontroller supply needs careful power sequencing, else you violate input voltage range
* ADC input can be negative (I see it should not happen in normal operating mode), it might violate input voltage range
code:
we don´t see the main loop, thus you need to check it on your own.
we dont see all the compiler setting variable values, thus you need to check them on your own.
we don´t see port setup, thus you need to check it on your own: especially
* Analog inputs (all)
* VRef input
* don´t leave any (unused) input floating. Neither digital ones nor analog ones.
It seems to be code from a code generator. You may omit all the "complier IFs" and shorten code to make it more readable.
Sadly with the given informations it´s hard to help.
SHOCK signal coms from an AOP witch has symetrical power supply
but RA0 AN0 can't measure negatives DC value !
a Rail to rail AOP could be better , even don't reach excatly Zero Volt..
it seems LOW BAT is used for comparator
compare with what ?
RA0 Analog value ?
RA3 is used for +VREF ? replaced by +VREF=+VDD
to test your RA0 analog input , begin to test with a Pot , like Pot R33
to separate problems from the analogue parts..
I did some test on a Curiosity nano board wit a PIC18F47Q10 , near same family as 25Q10
ADC is very much more sofisticate , more complex with a lot of additional functions
i tested first with classic ADC use .. and get results ...OK
MPLABX MCC is a powerfull tools/ Help for that. Have a look on this simple project ..
some issues:
* driving VRef from a 2.5KOhms source is rather optimistc.
* driving VRef without a capacitor to GND is a non go ( for me)
* driving Vref from another 5V source than the microcontroller supply needs careful power sequencing, else you violate input voltage range
* ADC input from another source than the microcontroller supply needs careful power sequencing, else you violate input voltage range
* ADC input can be negative (I see it should not happen in normal operating mode), it might violate input voltage range
Regarding schematic issues, we had this same schematic setup done to a different MCUIC16F876A-ISP (Schematic attached), it worked just fine! now I am just trying to upgrade the MCU and got too many problems.
Some points we can do for the design to improve such as points 2,3 and 4.
for point 5 we are aware of this and we plan to fix this in future versions.
code:
we don´t see the main loop, thus you need to check it on your own.
we dont see all the compiler setting variable values, thus you need to check them on your own.
we don´t see port setup, thus you need to check it on your own: especially
* Analog inputs (all)
* VRef input
* don´t leave any (unused) input floating. Neither digital ones nor analog ones.
It seems to be code from a code generator. You may omit all the "complier IFs" and shorten code to make it more readable.
Sadly with the given informations it´s hard to help.
these are the flags
The code posted before is not auto-generated, but we have posted code for both PICs so you can see the differences, and the conversion is done using ISR
#ifdef PIC16F876A_H
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#elif defined(PIC18F25Q10_H)
#pragma config WRTD = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config FEXTOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config XINST = OFF // Use extended instructions set
#pragma config LVP = OFF // Low-voltage programming disabled
#pragma config WRTB = ON // Boot Block write protected (1 = not write protected)
#endif
// Common configs
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
SHOCK signal coms from an AOP witch has symetrical power supply
but RA0 AN0 can't measure negatives DC value !
a Rail to rail AOP could be better , even don't reach excatly Zero Volt..
it seems LOW BAT is used for comparator
compare with what ?
RA0 Analog value ?
RA3 is used for +VREF ? replaced by +VREF=+VDD
to test your RA0 analog input , begin to test with a Pot , like Pot R33
to separate problems from the analogue parts..
I did some test on a Curiosity nano board wit a PIC18F47Q10 , near same family as 25Q10
ADC is very much more sofisticate , more complex with a lot of additional functions
i tested first with classic ADC use .. and get results ...OK
MPLABX MCC is a powerfull tools/ Help for that. Have a look on this simple project ..
AN0 does not read negative and it is not supposed to do that, so it's cool for us and as i mentioned we are working on a better version.
Low Bat indicates battery voltage level, it is not a comparator input, we use the voltage divider to make the MCU capable of reading the battery voltage level.