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

PIC16f15324 Pin A4 and Pin A5 not responding [solved]

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



Joined: 16 Apr 2007
Posts: 71
Location: Stuttgart, Germany

View user's profile Send private message Visit poster's website

PIC16f15324 Pin A4 and Pin A5 not responding [solved]
PostPosted: Tue Nov 22, 2022 5:57 am     Reply with quote

Hello,
I am trying to get Pin A4 and Pin A5 working on PIC16f15324.
CCS Compiler Version: 5.103
My code:
Code:

#include <16f15324.h>     
#fuses HS, NOCLKOUT, NOWDT,NOPROTECT,BROWNOUT,PUT,MCLR, BORV27
#use delay(clock=32000000)

#zero_ram
void main()
{
setup_oscillator (OSC_HFINTRC_32MHZ);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
while (1)
  {
  output_a(0xff);
  output_c(0);
  delay_ms(1);
  output_a(0x00);
  output_c(0xff);
  delay_ms(1);
  restart_wdt();
  }
}           // main ends


Port C toggles as expected.
Port A: Pin A0, Pin A1 and Pin A2 toggles as well.
But: Pin A4 and Pin A5 show no (re)action.
(I have tried 3 PCBs so I would exclude a hardware related problem.)

What could be the problem?

Michael


Last edited by mdemuth on Tue Nov 22, 2022 6:48 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Tue Nov 22, 2022 6:29 am     Reply with quote

You are enabling the external oscillator (HS fuse). Probably what is causing
the problem. You don't need to use setup oscillator. Try:
Code:

#include <16f15324.h>     
#fuses NOEXTOSC,NOWDT,NOPROTECT,BROWNOUT,PUT,MCLR, BORV27
#use delay(internal=32MHz)

#zero_ram
void main()
{
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   while (TRUE)
     {
     output_a(0xff);
     output_c(0);
     delay_ms(1);
     output_a(0x00);
     output_c(0xff);
     delay_ms(1);
     //restart_wdt(); //You haven't got the watchdog enabled.
  }
}           // main ends

Note the NOEXTOSC, and the changes to the clock settings.

as a comment, putting restart_wdt instructions inside code where they
can always be reached (if your watchdog was enabled), completely prevents
the watchdog from doing anything useful. The watchdog reset, needs to
_only_ be reachable if code is running properly. It is a 'bugbear' of mine
that the CCS 'inbuilt' operations that reset the watchdog for you (like
delay), show that they do not understand how a watchdog should be used.
mdemuth



Joined: 16 Apr 2007
Posts: 71
Location: Stuttgart, Germany

View user's profile Send private message Visit poster's website

PostPosted: Tue Nov 22, 2022 6:47 am     Reply with quote

Strike! Very Happy
Thanks!
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Nov 22, 2022 9:15 am     Reply with quote

comment : WDT

Generally speaking, do NOT enable the WDT until 100% of the program is 'up and running', ready to sell.

Usually set WDT to x2 or x3 the time for a 'main() loop' to occur ?

If it's enabled before, all sorts of weird and NOT wonderful things can happen, causing no end of grief....and hair pulling ......
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