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

I have problems whit timer2 on Pic 16f876

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
LLuis Miquel Condom
Guest







I have problems whit timer2 on Pic 16f876
PostPosted: Sat Jun 14, 2003 12:12 pm     Reply with quote

Using this configuration does not work. what is the problem???

#include "16f876.h"
#fuses HS, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
#use delay(clock=3276800)
//#use Delay(Clock=8000000)
#zero_ram

int_tmr2();
//-----------------------------------------------

main()
{
setup_timer_2(T2_DIV_BY_16,0x7d,10);

set_tris_c(0);

enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);

set_timer2(22);

while(1);
}

//-----------------------

#INT_TIMER2
int_tmr2()
{
output_high(pin_c3); // Create a positive pulse on PIN A3.
output_low(pin_c3);
}

thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515241
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

Re: I have problems whit timer2 on Pic 16f876
PostPosted: Sat Jun 14, 2003 4:14 pm     Reply with quote

:=Using this configuration does not work. what is the problem???
:=
:=#include "16f876.h"
:=#fuses HS, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
:=#use delay(clock=3276800)
:=//#use Delay(Clock=8000000)
:=#zero_ram
:=
:=int_tmr2();
:=//-----------------------------------------------
:=
:=main()
:={
:=setup_timer_2(T2_DIV_BY_16,0x7d,10);
:=
:=set_tris_c(0);
:=
:=enable_interrupts(INT_TIMER2);
:=enable_interrupts(GLOBAL);
:=
:=set_timer2(22);
:=
:=while(1);
:=}
:=
:=//-----------------------
:=
:=#INT_TIMER2
:=int_tmr2()
:={
:=output_high(pin_c3); // Create a positive pulse on PIN A3.
:=output_low(pin_c3);
:=}
:=
:=thanks

Should work.
set_timer2(22) will do nothing.

Code will give a pulse of around 2uS on C3 (not A3) every 10mS with 8MHz crystal.

setup_timer_2(T2_DIV_BY_16,0x7d,10);
Timer2 will interrupt every 0.5*16*125*10 = 10mS

Regards
Kenny
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515242
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