|
|
View previous topic :: View next topic |
Author |
Message |
LLuis Miquel Condom Guest
|
I have problems whit timer2 on Pic 16f876 |
Posted: Sat Jun 14, 2003 12:12 pm |
|
|
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
|
Re: I have problems whit timer2 on Pic 16f876 |
Posted: Sat Jun 14, 2003 4:14 pm |
|
|
:=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 |
|
|
|
|
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
|