View previous topic :: View next topic |
Author |
Message |
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
SOLVED: PIC16F18025 |
Posted: Thu Aug 17, 2023 10:29 am |
|
|
I can't seem to get this PIC to work.
Following code does not toggle pin. Looks like there are pulses of 500us every 2 sec, like a watchdog timeout. Any ideas please.
PCM Compiler Version 5.116
Code: | #include <16F18025.h>
#device ADC=10
#FUSES NOWDT //Watch Dog Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOPROTECT
#FUSES NOMCLR
//#FUSES NOEXTOSC
//#FUSES NOCLKOUT
#case
#use delay(internal=16000000)
void main() {
while(TRUE) {
output_toggle(PIN_A2);
delay_ms(200);
}
} |
Last edited by alan on Fri Aug 18, 2023 12:16 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Thu Aug 17, 2023 11:00 am |
|
|
The pins on these chips default to being setup as analog.
You need to turn this off (set_analog_pins()), otherwise the digital I/O
won't work. |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Thu Aug 17, 2023 11:37 am |
|
|
Thanks Ttelmah
Not the problem, behaviour the same.
Code: | #include <16F18025.h>
#device ADC=10
#FUSES NOWDT //Watch Dog Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOPROTECT
#FUSES NOMCLR
#use delay(internal=16000000)
void main() {
setup_adc(ADC_OFF);
set_analog_pins(0);
while(TRUE) {
output_toggle(PIN_A2);
delay_ms(200);
}
} |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Aug 17, 2023 7:43 pm |
|
|
curious, so I grabbed the datasheet..
it has PPS so......
..but...
your presented code doesn't show any PPS.... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Thu Aug 17, 2023 11:02 pm |
|
|
I must admit, my suspicion was that the toggle would not work
because this involves reading the pin, and then changing the result
from that. Because the pins wake up as analog, this would not work.
Try the experiment of setting the pin high, then low, instead of
toggling. If this works, we will then have to work out why the read
is not working. |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
SOLVED PIC16F18025 |
Posted: Fri Aug 18, 2023 12:15 am |
|
|
Thanks Ttelmah
Seems something happened in MPLAB and after reboot, it happily toggles my pin.
When I recompiled, it want to reload the file as it changed, but my guess is it never reloaded the file.
But project working 100% now. Thanks again |
|
|
|