View previous topic :: View next topic |
Author |
Message |
obidaa
Joined: 12 Dec 2012 Posts: 5
|
pic 12f675 timer1 interrupt |
Posted: Wed Dec 12, 2012 8:14 am |
|
|
please can anyone help me
timer1 dont work with external crystal 32.768
this is my pgm
main.c
#int_TIMER1
void TIMER1_isr(void)
{
output_high (pin_a1);
}
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_8|T1_CLK_OUT);
setup_comparator(NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
// TODO: USER CODE!!
while(1)
{
delay_ms( 500 );
output_high (pin_a0);
delay_ms( 500 );
output_low (pin_a0);
}
}
main.h
#include <12F675.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES NOCPD //No EE protection
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOPUT //No Power Up Timer
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BANDGAP_HIGH
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A2,rcv=PIN_A2,bits=8) |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Dec 12, 2012 9:30 am |
|
|
how do you know it wont work?
did you bother to build hardware?
you do realize you spec'd external clock right ?
OR ?? is only a student project simulation?
does it compile w/o error?
what compiler version are you using??
Last edited by asmboy on Wed Dec 12, 2012 9:34 am; edited 1 time in total |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Dec 12, 2012 9:33 am |
|
|
First:
- When posting code, use the 'code' buttons. This makes your code easier to read and will get you better response.
- Always post your compiler version.
I tried to compile your program in v4.140 but it failed with an error on the fuse BANDGAP_HIGH. I commented this line out but am very surprised it works for you. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Wed Dec 12, 2012 9:56 am |
|
|
T1_OSC_OUT is always required when you want to use the T1 input as an oscillator. By default enabling 'T1_EXTERNAL', just selects the input source to be from the T1 OSC1 pin, but does not enable the second pin as an output. This is what T1_OSC_OUT does.
I'd repeat the mantra 'compiler version' though, since the fuses don't agree with those from any compiler version I can find for the 675....
Best Wishes |
|
|
obidaa
Joined: 12 Dec 2012 Posts: 5
|
|
Posted: Wed Dec 12, 2012 3:12 pm |
|
|
thank you
i need use external clock for use 32768 Hz for small project clock
but not work in simulation proteus isis or mplab
thanks[/img] |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Wed Dec 12, 2012 3:57 pm |
|
|
You are still not answering the question posed by three people now. Compiler version?. Your code as posted _will not compile_ with any version I can find.... |
|
|
obidaa
Joined: 12 Dec 2012 Posts: 5
|
|
Posted: Thu Dec 13, 2012 12:03 am |
|
|
i am sorry i don't understand
my compile ccs 4.068 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Thu Dec 13, 2012 2:02 am |
|
|
OK. With 4.070, nearest I have to that compiler version, it compiles. Immediately, screamingly obvious fault. Fuses.
Replace 'INTRC', with 'INTRC_IO'.
Problem is you are telling the chip to put the master oscillator/4 out on the OSC2 pin, which you also want to use for the 32K crystal.....
Best Wishes |
|
|
obidaa
Joined: 12 Dec 2012 Posts: 5
|
|
Posted: Thu Dec 13, 2012 4:33 am |
|
|
i change INTRC to INTRC_IO but
in mplab timer1 not work
thank you for reaply |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Thu Dec 13, 2012 7:36 am |
|
|
You need to generate a stimulus file to simulate the clock, or the timer won't work.... |
|
|
obidaa
Joined: 12 Dec 2012 Posts: 5
|
|
Posted: Thu Dec 13, 2012 7:40 am |
|
|
thanks a lot |
|
|
|