![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
wavelength
Joined: 21 Mar 2014 Posts: 12
|
PIC12F509 coming up real slow or not at all? |
Posted: Mon Aug 28, 2017 11:28 am |
|
|
All,
I have a basic program with this setup:
Code: |
#include <12F509.h>
#fuses INTRC,NOWDT,NOPROTECT, NOMCLR
#use delay(clock=4000000)
|
I was doing a pretty elaborate wake from sleep and set the option registers and so forth, but the program was taking like 10 seconds before the LED's would come on. So I rewrote it yesterday to basic stuff and commented out all the wake on change and now it's not coming up at all. 5V power. All the IO is right and was kind of working when tested on wake from IO change. But I was running into some weird stuff so I pared it down to below.
Power switch input on B0, Select switch on B3.
Led on B1/B2 (bidirectional Red/Green), Power enable (enables a linear regulator) on B4 and 10ma relay on B5.
Code: |
main()
{
int i;
output_b(DEF_IO); // red LED on, power off, relay on
set_tris_b(TRIS_VAL);
delay_ms(500);
output_bit(LED_RED, 0);
output_bit(LED_GREEN, 1);
delay_ms(500);
output_bit(LED_RED, 1);
output_bit(LED_GREEN, 0);
delay_ms(500);
output_bit(LED_RED, 1);
output_bit(LED_GREEN, 1); // both LED's off
while(TRUE)
{
// main loop...
}
}
|
Any ideas?
Thanks,
Gordon _________________ J. Gordon Rankin
Wavelength Audio, ltd. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9170 Location: Greensville,Ontario
|
|
Posted: Mon Aug 28, 2017 12:16 pm |
|
|
If using MPLAB did you compile in 'debug' mode instead of 'release' mode ?
That WILL affect the PIC operation to be real, snail slow !!
BTDT...
Jay |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Mon Aug 28, 2017 2:06 pm |
|
|
Show us your defines. Currently a lot of detail is missing.
Ideally post the circuit. |
|
![](templates/subSilver/images/spacer.gif) |
wavelength
Joined: 21 Mar 2014 Posts: 12
|
|
Posted: Mon Aug 28, 2017 2:40 pm |
|
|
Guys,
Thanks, I use the CCS IDE... I was doing that code from memory as my dog messed up his spine at his tail bone fetching a ball. So I was at home typing the above.
I think the problem was that the #use delay(internal=4000000, RESTART_WDT) was set. I removed the RESTART_WDT and it appears like everything is working now.
Not sure why it would set that in the IDE Wizard, but it did. Not sure why it put internal in there instead of clock=4000000.
What's the difference? I am not using a timer so does that mean internal uses a timer and clock = software loop?
Thanks,
Gordon _________________ J. Gordon Rankin
Wavelength Audio, ltd. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Mon Aug 28, 2017 2:48 pm |
|
|
You are using internal. INTRC, means internal. Using internal in the clock statement, forces INTRC.
However there is a caveat. INTRC (and internal), both default to using pin B4 as the clock output on some compiler versions. The syntax to be sure this does not happen, is:
Code: |
#include <12F509.h>
#use delay(internal=4MHz)
#fuses INTRC_IO,NOWDT,NOPROTECT, NOMCLR
|
If this is being used to enable a linear regulator, some very odd behaviour can happen otherwise....
Seriously, forget the Wizard. It has no intelligence at all, and is likely to mislead you. You have to check what it does, so do it yourself. |
|
![](templates/subSilver/images/spacer.gif) |
wavelength
Joined: 21 Mar 2014 Posts: 12
|
|
Posted: Mon Aug 28, 2017 3:52 pm |
|
|
Ttelmah,
Thanks, but i did not see the INTRC_IO in the header file. The output on B4 does not have an oscillator output and seems to be working.
Gordon _________________ J. Gordon Rankin
Wavelength Audio, ltd. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Tue Aug 29, 2017 7:18 am |
|
|
As I said:
"on some compiler versions".
This was raised a little while ago in another thread (on a different processor). It depends on the processor defaults, and the compiler version. You can always look at the end of the .lst file, to see what fuses are actually being selected. Problem he was having was he selected INTRC_IO, and then used 'internal', and it was getting set to INTRC (which leaves the clock output on the pin).
The safe way is to use the INTRC_IO, but put it _after_ the clock line, which then ensures the fuse is set to INTRC_IO. |
|
![](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
|