CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

SOLVED: PIC16F18025

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
alan



Joined: 12 Nov 2012
Posts: 350
Location: South Africa

View user's profile Send private message

SOLVED: PIC16F18025
PostPosted: Thu Aug 17, 2023 10:29 am     Reply with quote

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: 19233

View user's profile Send private message

PostPosted: Thu Aug 17, 2023 11:00 am     Reply with quote

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: 350
Location: South Africa

View user's profile Send private message

PostPosted: Thu Aug 17, 2023 11:37 am     Reply with quote

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: 9118
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Aug 17, 2023 7:43 pm     Reply with quote

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: 19233

View user's profile Send private message

PostPosted: Thu Aug 17, 2023 11:02 pm     Reply with quote

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: 350
Location: South Africa

View user's profile Send private message

SOLVED PIC16F18025
PostPosted: Fri Aug 18, 2023 12:15 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group