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

pic 12f675 timer1 interrupt

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



Joined: 12 Dec 2012
Posts: 5

View user's profile Send private message

pic 12f675 timer1 interrupt
PostPosted: Wed Dec 12, 2012 8:14 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Wed Dec 12, 2012 9:30 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 12, 2012 9:33 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 12, 2012 9:56 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 12, 2012 3:12 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 12, 2012 3:57 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 13, 2012 12:03 am     Reply with quote

i am sorry i don't understand

my compile ccs 4.068
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Thu Dec 13, 2012 2:02 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 13, 2012 4:33 am     Reply with quote

Sad

i change INTRC to INTRC_IO but

in mplab timer1 not work



thank you for reaply
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Thu Dec 13, 2012 7:36 am     Reply with quote

You need to generate a stimulus file to simulate the clock, or the timer won't work....
obidaa



Joined: 12 Dec 2012
Posts: 5

View user's profile Send private message

PostPosted: Thu Dec 13, 2012 7:40 am     Reply with quote

thanks a lot
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