PDA

View Full Version : Can i use timer1 as a counter while using it by HPWM



tamersoss
- 17th January 2007, 12:29
Dear friends ...

I am making a code which generates a hardware pulse width modultaed frequency (HPWM) using HPWM command as follows :
HPWM 1,210,1340
then i want to measure time between ultrasonic signal transmission and receiving it again to measure distance ....
the problem is that i knew that hpwm uses timer1 and i am intending to use it for measuring time , Can this be done ? or there will be an conflict in operating timer1 for hpwm and as a time counter.

HenrikOlsson
- 17th January 2007, 13:20
Hi,
Actually, the datasheet (16F877), table 8-1 as well as figure 8-3 shows that the PWM generation uses TMR2, not TMR1. It DOES use the CPP1 module though but feel free to use TMR1 as you wish. You can use CPP1 for HPWM and CCP2 for capture/compare if that's what you want.

Note, this MAY be different on other PIC's but since you didn't say which one you're using a took the F877 as an example.

Hope it helps.
/Henrik Olsson.

tamersoss
- 18th January 2007, 12:59
Many thanks ... It seems that i was confused by the define
statement explained in the pic basic pro compiler manual
which showed defines to choose either timer1 or 2 for channel 2 or 3 in the pic17fxx series while i am using pic16f877a ... Many thanks for your concern .