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

PIC16LF1847 timer1 with external clock

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



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

PIC16LF1847 timer1 with external clock
PostPosted: Wed Dec 21, 2016 10:40 am     Reply with quote

Hello guys,

I'm not can do the timer1 work with a 32 kHz crystal.

The crystal is connected to pins T1OSI and T1OSO, with two 22pF capacitors

I wrote a simple code for testing, but it does not work.

Can anyone help ?


Code:
#include <16LF1847.h>
#device ADC=10

#FUSES HS
#FUSES NOWDT
#FUSES NOPUT                    // Power Up Timer
#FUSES NOMCLR                   // Master Clear pin used for I/O
#FUSES NOBROWNOUT               // No brownout reset
#FUSES NOFCMEN                  // Fail-safe clock monitor disabled
#FUSES NOLVP                    // No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(crystal=8000000)

#INT_TIMER1
void  TIMER1_isr(void)
{
  output_toggle(PIN_A0);
}

void main()
{

    //setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
 
   setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL);

   while(TRUE);   
}
temtronic



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

View user's profile Send private message

PostPosted: Wed Dec 21, 2016 10:46 am     Reply with quote

Ok...

does a 1Hz LED program work ?

NO timer stuff.....
Orcino



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

PostPosted: Wed Dec 21, 2016 11:04 am     Reply with quote

With, TIMER1_INTERNAL, work.

But TIMER1_EXTERNAL not work.
Ttelmah



Joined: 11 Mar 2010
Posts: 19328

View user's profile Send private message

PostPosted: Wed Dec 21, 2016 11:13 am     Reply with quote

It wouldn't.... Twisted Evil

The reason is that you have it set to use an external _clock_ not an external _crystal_.

If you look a the data sheet, you will see that the default 'external' configuration is a clock input. To use the external crystal, you have to enable the oscillator.

T1_EXTERNAL | T1_ENABLE_T1OSC
Orcino



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

PostPosted: Wed Dec 21, 2016 11:20 am     Reply with quote

Yahooo, work now.

Very thanks Ttelmah.

I owe you a Coke.
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