On Sun, 10 Aug 1997 20:57:14 -0400 Jeff King writes: >At 01:11 AM 8/11/97 -0700, Andre Abelian wrote: >>HI PIC Engineers. >> >>I am using pic16c62 portb as output >>I am driving LEDS and one buzzer. >>Buzzer gets distorted signal. >>I checked with digital scope I get this >> >> >> >> >> >>-----------------|-|--------------- >> | | >> | | >> | | >> | | >> |_| >> >> >> I use BSF portb,RB3 ; sound when is high >> >> >>My question is when you set any bit high shouldn't I get >>clean 5 v signal or to have little distortion is normal. >> >>How do you use buzzers with pics. I assume it is a piezo buzzer with built-in oscillator. These should work fine directly from a port pin, as long as it uses less than 20 mA. Electromechanical buzzers of the type with contact points are a definite no-no since they will send nasty surges back into the PIC. Bare piezo elements need you to clock out a signal of the proper frequency. Possible sources of your trouble: (a) There is a bug in the software, setting the port pin low or configuring it for input when it isn't supposed to. This will naturally turn the buzzer off. (b) The buzzer is overloading the port pin. Check that the voltage is close to 5V when the buzzer should be on. If not, other read-modify write instructions to the port will turn it off even though they're not supposed to. If the buzzer contains a capacitor in series with its power supply it can create a transient overload that would cause a following bsf or bcf to malfunction. My advice is not to use bsf/bcf [port pin], xorwf [port],f etc. on ports that have any of their pins driving heavy loads. (c) The WDT is resetting the whole chip periodically. This will make the ports go to inputs and turn the buzzer off until the tris registers are set up again. Of course it will cause a lot of other problems as well, which you may not be noticing because you're only trying to test the buzzer now. Make sure WDT Off is selected in your programmer unless you have clrwdt instructions in the proper place in the program. This is about #2 on the list of PIC newbie mistakes.