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 CCS Technical Support

Problem with clock pic16f1937

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



Joined: 15 Oct 2011
Posts: 36

View user's profile Send private message

Problem with clock pic16f1937
PostPosted: Sun Nov 13, 2011 10:27 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 13, 2011 10:54 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 13, 2011 12:38 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 13, 2011 3:34 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 13, 2011 3:54 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Nov 15, 2011 1:34 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Nov 15, 2011 1:48 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Nov 15, 2011 2:03 pm     Reply with quote

Look at the top of the 16F1937.h file to find the list of available fuses.
Lemosek



Joined: 15 Oct 2011
Posts: 36

View user's profile Send private message

PostPosted: Tue Nov 15, 2011 3:18 pm     Reply with quote

Thank You one more time. I'm the beginner in ccs.
Best regards
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