View previous topic :: View next topic |
Author |
Message |
Lemosek
Joined: 15 Oct 2011 Posts: 36
|
Problem with clock pic16f1937 |
Posted: Sun Nov 13, 2011 10:27 am |
|
|
Hello,
I have problem with clock at pic 16f1937. I have connected crystal 8MHz and two capacitors 18p. Code at pic:
Code: |
#include <16F1937.h>
#device *=16
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT, NOVCAP
#use delay(clock=32M)
#use rs232(baud=9600, UART1, stream=PC, ERRORS)
and in main loop
while(1)
{
delay_ms(1000);
LED1ON
delay_ms(1000);
LED1OFF;
printf("Test");
}
|
When I put #use delay(clock=8M) like connected crystal, pic is faster, only work correctly when i have #use delay(clock=32M).
What I doing wrong? I don't set PLL but clock is 4x8MHz.
Best regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Nov 13, 2011 10:54 am |
|
|
Compiler version???
Try with:
Code: |
#include <16F1937.h>
#device *=16
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT, NOVCAP
#use delay(crystal=8M, clock=8M)
#use rs232(baud=9600, UART1, stream=PC, ERRORS)
and in main:
setup_oscillator(OSC_NORMAL);
|
Have a memory of some compiler versions setting the PLL by default. This makes sure it is turned off....
Best Wishes |
|
|
Lemosek
Joined: 15 Oct 2011 Posts: 36
|
|
Posted: Sun Nov 13, 2011 12:38 pm |
|
|
Hello,
My compiler is: 4.120.
I tried Your code but nothing change.
Where I find this option about pll, I use default IDE from CCS.
best regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Nov 13, 2011 3:34 pm |
|
|
How are you writing this to the chip?.
I tested with this setup code, and running a basic flash for one second routine, it works correctly with your compiler version.
If you are running through the debugger though, the PLL won't change till the chip is reset. Or if you are using a bootloader, these (generally) won't change the PLL.
Best Wishes |
|
|
Lemosek
Joined: 15 Oct 2011 Posts: 36
|
|
Posted: Sun Nov 13, 2011 3:54 pm |
|
|
I compiled my code in IDE and load hex file by pickit2 in to pic.
Can you do it test with rs232. Send something with #use delay(clock=8M) and #use delay(clock=32M). Because in my circuit it work correctly only #use delay(clock=32M).
Best regard |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Nov 15, 2011 1:34 pm |
|
|
Disable the PLL by adding the #fuse shown below:
Quote: |
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT, NOVCAP,PLL_SW
|
|
|
|
Lemosek
Joined: 15 Oct 2011 Posts: 36
|
|
Posted: Tue Nov 15, 2011 1:48 pm |
|
|
Hello, dear PCM programmer thank You so much now is ok. Everything works correct.
P.S.
In the manual ccs I can't find this fuse.
best regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Nov 15, 2011 2:03 pm |
|
|
Look at the top of the 16F1937.h file to find the list of available fuses. |
|
|
Lemosek
Joined: 15 Oct 2011 Posts: 36
|
|
Posted: Tue Nov 15, 2011 3:18 pm |
|
|
Thank You one more time. I'm the beginner in ccs.
Best regards |
|
|
|