Setup the PIC on a regular breadboard and get it working. This eliminates any problems related to wiring, solder blobs, or the board is being used. Then move the working (programmed) chip to the board and troubleshoot.
I have set up 16F15355 on a breadboard with Franks code and a 10K pot and it all works fine. This tells me that there is not a problem with the compiler or with the ADC-Library.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I downloaded the trial version of PBP3 and tried this:
DEFINE OSC 32
Include "modedefs.bas"
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
adval VAR WORD ' Create adval to store result
ANSELA = %00000100
ADCON0 = %11101110
ADCON1 = %1111000
TRISA = %11111111 ' Set PORTA to all input
Serout PORTC.1,T9600,["16F15323",10,13]
start:
ADCIN 2, adval ' Read channel 0 to adval
Serout PORTC.1,T9600,["value: ",#adval,10,13]
goto start
Ok, the oscillator runs here with 32MHz but the ADC seems to work!!!!! I get the values what I expected! "0" with a connection to GND and a slightly changing value around 50000. With an additional resistor against + I get values around 33600.
My circuit seems to be ok!
I have attached the asm-file with it...
Thanks. The ASM looks the same. There is one piece that could be in error but I would need the chip here - the dat file could be incorrect and we have something not correct.
Wait please.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, I implemented a poti (5V/GND) in my circuit and reflashed my chip with the PBP3 code - the ADC works perfectly with this PBP3 code.
With the last GCB code I posted AND with your last changes (#define ADSpeed LowSpeed/#define AD_Delay 6 10us) I GET ALWAYS "0"!!!
When I programmed the µC with the GCB code, I had the potentiometer with the PBP code set to +5V => value of approx. 65400.
After reprogramming with the GCB code, the output remained at 65400!!
Only since the restart only "0" is displayed!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Try these things - this is what I will do when the chip arrives.... in the other compiler, print out the values of ANSELA, ADCON0 ADCON1 and TRISA. What these values?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ADCON1 set to that value is meaningless This would set the ADC Conversion Clock Select bits to a ADCRC (dedicated RC oscillator), so, they are reseting the register after reading.
This is hard without a chip, but,
#define ADReadPreReadCommand ADCON0 = 0x09
I have sent you a Personal Message - so, we can chat via Google Chat. This is painful.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The demonstration shows how to setup the ADC be remapping the LLREAD macro to a user macro (called myLLREAD) so that you can isolate this type of issue. The beauty of this method is that the public functions of Great Cow BASIC are retained whilst providing a specific ADC set method for a specific microcontroller.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is what I would do ..
Setup the PIC on a regular breadboard and get it working. This eliminates any problems related to wiring, solder blobs, or the board is being used. Then move the working (programmed) chip to the board and troubleshoot.
I have set up 16F15355 on a breadboard with Franks code and a 10K pot and it all works fine. This tells me that there is not a problem with the compiler or with the ADC-Library.
@William. Good stuff. i am with you. Thanks for testing and posting the positive results.
Hi to all,
I downloaded the trial version of PBP3 and tried this:
Ok, the oscillator runs here with 32MHz but the ADC seems to work!!!!! I get the values what I expected! "0" with a connection to GND and a slightly changing value around 50000. With an additional resistor against + I get values around 33600.
My circuit seems to be ok!
I have attached the asm-file with it...
OK. I am reviewing the ASM.
Did you add to your code?
Yes - it comes directly after "#config mclr_off, WDT_Off"...
What that the LST file or the ASM file you posted?
...here is it!
Thanks. The ASM looks the same. There is one piece that could be in error but I would need the chip here - the dat file could be incorrect and we have something not correct.
Wait please.
Please add this to your code, test and report back.
Hi,
I inserted the line directly for the loop - unfortunately no change... : - (
So, those were the settings for the registers from the other compiler. Odd
Please to try increase read delay.
`#define ADSpeed LowSpeed
define AD_Delay 6 10us`
...no change! This is my code at the moment:
You have one item commented out and the delay can/should be increased.
Sorry, I misunderstood you!
Ok, I implemented a poti (5V/GND) in my circuit and reflashed my chip with the PBP3 code - the ADC works perfectly with this PBP3 code.
With the last GCB code I posted AND with your last changes (#define ADSpeed LowSpeed/#define AD_Delay 6 10us) I GET ALWAYS "0"!!!
When I programmed the µC with the GCB code, I had the potentiometer with the PBP code set to +5V => value of approx. 65400.
After reprogramming with the GCB code, the output remained at 65400!!
Only since the restart only "0" is displayed!
Whilst we wait for a chip here.
Try these things - this is what I will do when the chip arrives.... in the other compiler, print out the values of ANSELA, ADCON0 ADCON1 and TRISA. What these values?
I get this back after inserting this:
Serout PORTC.1,T9600,["ANSELA: ",#ANSELA,10,13]
Serout PORTC.1,T9600,["ADCON0: ",#ADCON0,10,13]
Serout PORTC.1,T9600,["ADCON1: ",#ADCON1,10,13]
Serout PORTC.1,T9600,["TRISA: ",#TRISA,10,13]
Output:
ANSELA: 4
ADCON0: 9
ADCON1: 112
TRISA: 63
Sorry, did you insert after reading the ADC? I need the values after the read operation.
Ok, I changed the values from GCB to the values from PBP - no change! It seems it is another register which is wrong...
What did you change?
I read it in a loop. Now I changed it to:
=> same values!
I changed my GCB file to:
ADCON1 set to that value is meaningless This would set the ADC Conversion Clock Select bits to a ADCRC (dedicated RC oscillator), so, they are reseting the register after reading.
This is hard without a chip, but,
I have sent you a Personal Message - so, we can chat via Google Chat. This is painful.
Silly question: ...where is here my personal message folder?
I have sent you a mail - your address is still the same?
Sorry, I have no Google account... - I mailed you again...
I have resolved this issue. See this demonstration. See https://github.com/Anobium/Great-Cow-BASIC-Demonstration-Sources/blob/master/ADC%20Read%20Solutions/Reading_a_specific_ADC_Port/Read_a_specific_ADC_Port_using_Optimised_LLRead.gcb
The demonstration shows how to setup the ADC be remapping the LLREAD macro to a user macro (called myLLREAD) so that you can isolate this type of issue. The beauty of this method is that the public functions of Great Cow BASIC are retained whilst providing a specific ADC set method for a specific microcontroller.
Hi Frank,
We have found the problem. There is an incorrect bitname in the chip datafile for 16F15323. This has been corrected in the latest AD-H library.
Please download and install the new AD.H library SourceForge ==> . HERE
.
Please let us know the result
William
Last edit: William Roth 2017-12-09