View previous topic :: View next topic |
Author |
Message |
Orcino
Joined: 07 Sep 2003 Posts: 56
|
PIC16LF1847 timer1 with external clock |
Posted: Wed Dec 21, 2016 10:40 am |
|
|
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: 9225 Location: Greensville,Ontario
|
|
Posted: Wed Dec 21, 2016 10:46 am |
|
|
Ok...
does a 1Hz LED program work ?
NO timer stuff..... |
|
|
Orcino
Joined: 07 Sep 2003 Posts: 56
|
|
Posted: Wed Dec 21, 2016 11:04 am |
|
|
With, TIMER1_INTERNAL, work.
But TIMER1_EXTERNAL not work. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Wed Dec 21, 2016 11:13 am |
|
|
It wouldn't....
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
|
|
Posted: Wed Dec 21, 2016 11:20 am |
|
|
Yahooo, work now.
Very thanks Ttelmah.
I owe you a Coke. |
|
|
|