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

timer1 setup!!

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 05, 2006 8:34 pm     Reply with quote

My first comment is that you have way too much code to test this problem.
Notice how small my program is. Smaller is better, when investigating
a problem.

The following program works OK on the PicDem2-Plus board.
It blinks LED "RB0" at a rate of 2 seconds on, and then 2 seconds off.
This is correct, because with a 32.768 KHz crystal, it will take 2 seconds
to make Timer1 count from 0x0000 to 0xFFFF and then overflow to
0x0000 to create the interrupt.

Also make sure that you have jumper J6 installed. This jumper
enables the LEDs.

Code:
#include <18F452.H>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay (clock=4000000)

#int_timer1
void timer1_isr(void)
{
 output_toggle(PIN_B0);
}

//==================================
void main()
{
output_low(PIN_B0);

setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1 | T1_CLK_OUT);

enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);

while(1);
}
Agios



Joined: 28 Jan 2006
Posts: 8
Location: Brighton

View user's profile Send private message

PostPosted: Mon Feb 06, 2006 8:22 am     Reply with quote

Thank you PCM programmer for your reply. From what you have written in the post I realized that my formula should be modified for the TIMER 1 with the external 32768KHz clock attached. The delay calculation formula will therefore be: Delay = [65536(2 to the power of 16) * 1 (instruction cycle) * 1 (prescaler) ] / 32768. Now it makes sense. Thank you all for your help.

Regards

Agios
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