I can't get the ADC on a 16F15323 working. I get only "0" without voltage (GND) and "512" with any voltage after a new power on! This means I get ALWAYS "0" with GND on my ADC on startup (changing to any voltage has no effect) and I get ALWAYS "512" with voltage at startup even if I remove the voltage (short to GND).
Here is my code - did I do something wrong?
'* *** (Compiled with GCB 0.98.010) *** *'*** Initialisation ***
'Select chip model and speed
#chip 16F15323
#config mclr_off, WDT_Off
#define DEBUG_TRANS PORTC.1 'TxD Pin for debugging
'*** Config Software-UART ***
Dir DEBUG_TRANS Out
#define SendAHigh Set DEBUG_TRANS ON
#define SendALow Set DEBUG_TRANS OFF
InitSer 1, r19200, 1+WaitForStart, 8, 1, None, Normal
Set DEBUG_TRANS ON
SerPrint 1, " PIC 16f15323"
SerSend 1, 13 ' "Carriage Return"
SerSend 1, 10 ' "Line Feed"
do
SerPrint 1,readad10(AN2)
SerSend 1, 13 ' "Carriage Return"
SerSend 1, 10 ' "Line Feed"
wait 200 ms
loop
End
Thank you very much for any help!!!
Frank
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sister chip: 16F15355. results range from 0 to 1022. That is the OK.
Only change was the chip, chip frequency, debug port and the LED toggle. I have tried with frequency missing no different. My code is shown below: So looks ok on this chip - I have got one coming here.
I tried this at the moment (with and without your GCB Optimisation) - both with no success - its always the same result: The output is always "0" or "512" after a new powering - changing the voltage has no effect during runtime:
'*** Initialisation ***
'Select chip model and speed
#chip 16F15323,32
#config mclr_off, WDT_Off
#define ADSpeed LowSpeed
#define AD_Delay 4 10us
#define DEBUG_TRANS PORTC.1 'TxD Pin for debugging
'*** Config Software-UART ***
Dir DEBUG_TRANS Out
#define SendAHigh Set DEBUG_TRANS ON
#define SendALow Set DEBUG_TRANS OFF
InitSer 1, r19200, 1+WaitForStart, 8, 1, None, Normal
Set DEBUG_TRANS ON
SerPrint 1, " PIC 16f15323"
SerSend 1, 13 ' "Carriage Return"
SerSend 1, 10 ' "Line Feed"
dir porta.0 out
do
SerPrint 1,readad10(AN2)
SerSend 1, 13 ' "Carriage Return"
SerSend 1, 10 ' "Line Feed"
wait 200 ms
porta.0 = ! porta.0
loop
End
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Unless someone has got an insight - wait.. but! there are lots of smarted folks than me maybe we are missing the obvious It will take a few days for the chip to arrive then I can test on the same chip.
Really puzzled, I checked the errata - nothing there. I also checked using MPLAB-IDE our code looks same.
As William Roth always tells me... there is nothing like real silicon!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, I found only a problem with the compare module in the errata. This chip has different reference sources and internal temperature sensor - are you sure that all settings are automatically set correctly? I have problems to understand all the settings in the datasheet - otherwise I would have tried to configure the chip manually...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes - I thinking things are correctly, I wrote major parts of the library. I will be corrected if it is incorrect by folks which means we all benefit.
What is really puzzling me the same family chips work.
Post a photo of you board etc. Whilst I wait for a chip let us look at the board/layout. I have a 10k pot with the wiper connected to the Pic port, 0v and 5v are connect to the other connections of the pot. Like this i also have 5v and 0v to the PIC with a cap between 5v and 0v for decoupling. What is your layout?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Evan,
thank you very much for your effort!
I have in the moment a 4K7 between Pin RA2 and GND and a second 4K7 to 7.5V which I connect to RA2 when required. I measure about 3.8V to RA2 with both resistors.
The PIC is supplied with 5V via an MCP1702. At the end, everything together should become a battery-operated application which only takes one measurement every minute.
I should have enough capacitors on my MCP1702 and a 100nF between Vcc and GND on my PIC.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Photo is a problem at the moment...
The board was designed for an 8-pin chip, but I had to change to a 14-pin chip...
The 16F15323 is currently hung on an adapter board above the actual carrier board and is wired with individual wires.
I'm gonna try another chip to make sure it's not damaged.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried another chip - similar, but also strange behavior! With GND on startup I get "0" - no changing with another voltage on input. With voltage on startup I get mostly "4096", sometimes "4224" and "129"... - no changing of the output when input changed to GND...
...the first chip was much more stable with the "512" output...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Pull apart the board, do you have a 10k pot/pic that you can test on a bread board? Get the setup really cleaned up - there is no reason for these reading that I can think of.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have no poti available at the moment - but there is only a change of the output after a new start! :-( I've never seen one behave like this before on an ADC...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi to all,
I can't get the ADC on a 16F15323 working. I get only "0" without voltage (GND) and "512" with any voltage after a new power on! This means I get ALWAYS "0" with GND on my ADC on startup (changing to any voltage has no effect) and I get ALWAYS "512" with voltage at startup even if I remove the voltage (short to GND).
Here is my code - did I do something wrong?
Thank you very much for any help!!!
Frank
Try this,
'Set the input pin direction
Dir PORTA.2 In
Hi Evan,
I tried this before (and tried it in the moment again) - same result!
Frank
Looking at the asm.
- ANSEL looks correct.
- ADCON0.CHx looks correct
I may have messed up my ASM review but nothing is jumping out at me.
Try another port? AN3?
Does anyone else have the same chip?
This chip has no AN3 - I tried AN4 - ALWAYS "0" !?! :-(
I can get a chip if not one else has this chip. Will take a week to obtain a chip.
...I have a chip here - but I don't think it's really going to go any faster if I send it from here...
I am going to ask... do you have a consistent build? Update a-d.h to https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/lowlevel/a-d.h
...I downloaded it and replaced it - no change...
Sister chip: 16F15355. results range from 0 to 1022. That is the OK.
Only change was the chip, chip frequency, debug port and the LED toggle. I have tried with frequency missing no different. My code is shown below: So looks ok on this chip - I have got one coming here.
Please check connectivity and try
My code for the 16F15355
16F15356 and 16F15355 - work but this is not to say the the 16F15323 will work. I have tried and tested the 16F15356 and 16F15355 - both work.
If I use HighSpeed then I do get 0 returned but this would make sense - so, do try LowSpeed
I tried this at the moment (with and without your GCB Optimisation) - both with no success - its always the same result: The output is always "0" or "512" after a new powering - changing the voltage has no effect during runtime:
Unless someone has got an insight - wait.. but! there are lots of smarted folks than me maybe we are missing the obvious It will take a few days for the chip to arrive then I can test on the same chip.
Really puzzled, I checked the errata - nothing there. I also checked using MPLAB-IDE our code looks same.
As William Roth always tells me... there is nothing like real silicon!
Yes, I found only a problem with the compare module in the errata. This chip has different reference sources and internal temperature sensor - are you sure that all settings are automatically set correctly? I have problems to understand all the settings in the datasheet - otherwise I would have tried to configure the chip manually...
Yes - I thinking things are correctly, I wrote major parts of the library. I will be corrected if it is incorrect by folks which means we all benefit.
What is really puzzling me the same family chips work.
Post a photo of you board etc. Whilst I wait for a chip let us look at the board/layout. I have a 10k pot with the wiper connected to the Pic port, 0v and 5v are connect to the other connections of the pot. Like this
i also have 5v and 0v to the PIC with a cap between 5v and 0v for decoupling. What is your layout?
Hi Evan,
thank you very much for your effort!
I have in the moment a 4K7 between Pin RA2 and GND and a second 4K7 to 7.5V which I connect to RA2 when required. I measure about 3.8V to RA2 with both resistors.
The PIC is supplied with 5V via an MCP1702. At the end, everything together should become a battery-operated application which only takes one measurement every minute.
I should have enough capacitors on my MCP1702 and a 100nF between Vcc and GND on my PIC.
Ok. Sounds ok to me. At no time have you applied 7.5 to the chip?
I will wait till I get a chip to help further unless someone else spot an error.
No - there was not more than 4.3V on RA2. Thanks again!
Can you check that you have a common 0v rail between the chip and the pot.
A foto of the setup would help.
Photo is a problem at the moment...
The board was designed for an 8-pin chip, but I had to change to a 14-pin chip...
The 16F15323 is currently hung on an adapter board above the actual carrier board and is wired with individual wires.
I'm gonna try another chip to make sure it's not damaged.
Good idea.
I tried another chip - similar, but also strange behavior! With GND on startup I get "0" - no changing with another voltage on input. With voltage on startup I get mostly "4096", sometimes "4224" and "129"... - no changing of the output when input changed to GND...
...the first chip was much more stable with the "512" output...
Pull apart the board, do you have a 10k pot/pic that you can test on a bread board? Get the setup really cleaned up - there is no reason for these reading that I can think of.
I have no poti available at the moment - but there is only a change of the output after a new start! :-( I've never seen one behave like this before on an ADC...
Let us wait till I get my chip. A few days to go.