![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
mdemuth
Joined: 16 Apr 2007 Posts: 71 Location: Stuttgart, Germany
|
PIC16f15324 Pin A4 and Pin A5 not responding [solved] |
Posted: Tue Nov 22, 2022 5:57 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Nov 22, 2022 6:29 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
mdemuth
Joined: 16 Apr 2007 Posts: 71 Location: Stuttgart, Germany
|
|
Posted: Tue Nov 22, 2022 6:47 am |
|
|
Strike!
Thanks! |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Tue Nov 22, 2022 9:15 am |
|
|
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 ...... |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|