16F15325 blink a led

23 views
Skip to first unread message

hans

unread,
Apr 20, 2023, 5:05:50 AM4/20/23
to jallib
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
16f15325_blink_intosc_H.jal
16f15325_nrf24l01_HANS_RECEIVE.jal
16f15325_nrf24l01_hANS_SEND.jal

hans

unread,
Apr 20, 2023, 6:35:15 AM4/20/23
to jallib
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:

hans

unread,
Apr 22, 2023, 9:50:55 AM4/22/23
to jallib
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:

Rob CJ

unread,
Apr 22, 2023, 10:00:03 AM4/22/23
to jallib
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: jal...@googlegroups.com <jal...@googlegroups.com> namens hans <hanz...@zeelandnet.nl>
Verzonden: zaterdag 22 april 2023 15:50
Aan: jallib <jal...@googlegroups.com>
Onderwerp: [jallib] Re: 16F15325 blink a led
 
--
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 jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/c733f6eb-f4ba-4822-b79f-974ca34dc7f1n%40googlegroups.com.

hans

unread,
Apr 22, 2023, 11:24:11 AM4/22/23
to jallib
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:

Rob CJ

unread,
Apr 22, 2023, 11:32:57 AM4/22/23
to jallib
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


Verzonden: zaterdag 22 april 2023 17:24
Aan: jallib <jal...@googlegroups.com>
Onderwerp: Re: [jallib] Re: 16F15325 blink a led
 
16f15325_adc.jal
adc.jal
Reply all
Reply to author
Forward
0 new messages