piclist 2001\01\19\043611a >
Thread: PIC16F877 - PWM&JAL five second beep.
www.piclist.com/techref/microchip/ios.htm?key=pwm
flavicon
face BY : Vasile Surducan email (remove spam text)



Five seconds beep, one second pause...


var bit pwm1 is pin_c2
-- pin_c2_direction = output

var byte lenght = 5
var byte pause  = 1

procedure frequency ( byte in period, byte in prescale ) is
asm movf  period, w
bank_1
asm movwf f877_pr2
bank_0
 f877_ccpr1l = period / 2       -- set duty cycle at approx 0.5
 pin_c2_direction = output

  if prescale == 16 then
    f877_t2con = 0b_0000_0110   -- tmr2 on, prescale=16
  elsif prescale == 4 then
    f877_t2con = 0b_0000_0101   -- tmr2 on, prescale=4
  elsif prescale == 1 then
    f877_t2con = 0b_0000_0100   -- tmr2 on, prescale=1
  end if
 f877_ccp1con = 0b_0000_1100    -- pwm mode on
end procedure


procedure stop is
delay_1S ( lenght )
f877_ccp1con = 0             -- PWM off
delay_1S ( pause )
end procedure

procedure DO1  is frequency ( 238, 16 ) stop end procedure
procedure MI1  is frequency ( 189, 16 ) stop end procedure
procedure SOL1 is frequency ( 158, 16 ) stop end procedure
procedure DO2  is frequency ( 118, 16 ) stop end procedure


-- main program

forever loop

DO1  MI1 SOL1  DO2

end loop




On Thu, 18 Jan 2001, Tom Mariner wrote:

{Quote hidden}

> {Original Message removed}
<Pine.LNX.4.20.0101191043000.2941-100000@L30.itim-cj.ro>

In reply to: <001701c08164$bbcf1f80$6a8abc18@qmiguest>
See also: www.piclist.com/techref/microchip/ios.htm?key=pwm
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) PIC16F877 - PWM&JAL five second beep.

month overview.

new search...