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: > Is this a trick question? Out of the infinite ways of bit banging and > hardware, I would choose to use the PWM. > > On the other hand, I'll bet that there is something else going on in the > device or you would be using a 12 series. The deal is to write your code > with a mini-RTOS so that lots of things can happen "at once". I still would > fire up the PWM and let it do its task if a square wave is all that is > required. I'd still use the PWM for the sampling frequency if a more complex > audio waveform is needed. > > Tom Mariner > > -----Original Message----- > From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU] On > Behalf Of Paul Chicofsky > Sent: Wednesday, January 17, 2001 5:40 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]:PIC16F877 > > Hi all > > Any body know how to program the pic16f877 so it outputs a beep to a speaker > for only 5 seconds? > > Thank you > > Samer > > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.