Hi Hans, I adapted the adc library so it also works for your PIC and made a sample file for your PIC as well. I tested it and it works OK.
Note that for this sample file I used RA2 and RC2 for 2 reasons: 1. Easy testing since the the pins for the programmer do not interfere (they are on RA0 and RA1). 2. I wanted to inform users that the channel numbers have to be checked with the datasheet. So in this case RA2 = channel 2 and RC2 = channel 18. I called the sample just 16f15325_adc.jal. I am not sure why 'dependent' and independent' where used in the past, maybe that was important before the adc library was adapted. I used one of the previous sample files but made some modifications because of the use of other channel numbers. Attached you find the update of the adc library and the sample file for your PIC. I will add this to GitHub so it will be in the bee-package of coming Sunday. Kind regards, Rob ________________________________ Van: [email protected] <[email protected]> namens hans <[email protected]> Verzonden: zaterdag 22 april 2023 17:24 Aan: jallib <[email protected]> Onderwerp: Re: [jallib] Re: 16F15325 blink a led I have read the data sheet, I have slept with it, dreamed of it……(wouter said once) …. A nightmare. May you all just solve this !!!!!!!! WOW Op zaterdag 22 april 2023 om 16:00:03 UTC+2 schreef Rob CJ: Hi Hans, There are two issues: 1. ADCON1_ADNPREF does not exist so should be removed. 2. The adc library assumes a register called ADCON0_GO but it is called ADCON0_GONDONE for this chip. I added an alias to solve that (will also fix it in the adc library. So this code compiles. -- Step 1: ADC analog input pin setup const byte ADC_CHANNEL = 2 -- Potmeter connected to pin_A2 ANSELA_ANSA2 = TRUE -- Channel 2is analog input -- Step 2: Set VDD and VSS as Vref ADCON1_ADPREF = 0b00 -- Step 3: Use Frc as ADC clock ADCON1_ADCS = 0b111 const ADC_RSOURCE = 10_000 -- Input resistance: 10K potmeter -- Define alias to solve problem with ADC library alias ADCON0_GO is ADCON0_GONDONE -- Now we can include the library include adc -- And initialize the whole with our parameters adc_init() Kind regards, Rob ________________________________ Van: [email protected] <[email protected]> namens hans <[email protected]> Verzonden: zaterdag 22 april 2023 15:50 Aan: jallib <[email protected]> Onderwerp: [jallib] Re: 16F15325 blink a led Thanks to Rob I got the beginning of my circuit working but now I'm stuck with another problem. I want to use pin_A2 as analog input and have used the basics below have tried everything. I now get all sorts of errors, both in the 16F15325 lib and also in e adc lib. Can someone help me with the right setting? -- Step 1: ADC analog input pin setup ?????const byte ADC_CHANNEL = 2 -- Potentiometer connected to pin_A2 ?????ANSELA_ANSA2 = TRUE -- Channel 2 is analog input -- Step 2: Set VDD and VSS as Vref ?????ADCON1_ADPREF = 0b00 ?????ADCON1_ADNREF = FALSE -- Step 3: Use Frc as ADC clock ADCON1_ADCS = 0b111 ?????const ADC_RSOURCE = 10_000 -- Input resistance: 10K potentiometer -- Now we can include the library ????include adc -- And initialize the whole with our parameters ?????adc_init() Op donderdag 20 april 2023 om 12:35:15 UTC+2 schreef hans: Sorry, have used a damaged led, now the blink is working. Up to the next step. Op donderdag 20 april 2023 om 11:05:50 UTC+2 schreef hans: I am working with the 16F15325 to use for the NRF24101 but it does not work. So i have tried the blink a led from the sample and that works also not. Used anaother pic.. same result. atached the files The old man's problems??? Hans -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/c733f6eb-f4ba-4822-b79f-974ca34dc7f1n%40googlegroups.com<https://groups.google.com/d/msgid/jallib/c733f6eb-f4ba-4822-b79f-974ca34dc7f1n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/233e7b34-8e10-4c26-bb02-02758e70c744n%40googlegroups.com<https://groups.google.com/d/msgid/jallib/233e7b34-8e10-4c26-bb02-02758e70c744n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/GVXP195MB16378C6CD9B7D820ADD2DE8CE6619%40GVXP195MB1637.EURP195.PROD.OUTLOOK.COM.
16f15325_adc.jal
Description: 16f15325_adc.jal
adc.jal
Description: adc.jal
