Depending on value, SOUND statement leaves port output high
Which leads to disastrous results, if you have passive buzzer connected thru transistor :)
For example,
PIC16F1828.
Sound PORTB.6,[115,1] - ok
Sound PORTB.6,[116,1] - port is left high
So when called, first statement works fine, if 2nd statement uses same frequency, it is also fine, but if 2nd statement uses different frequency, then port is left high. However, if I call the statement 3rd time, again, with different frequency, then port is turned low.
Technically, this is not a big issue - I just modified my code and added LOW PORTB.6 everywhere, after the SOUND statement, but I'm curious, is this bug or a feature?
Re: Depending on value, SOUND statement leaves port output high
I think it's just the way it works, and probably depends on the timing since SOUND just toggles the IO pin to produce the output.
The manual shows using an inline capacitor to block the DC output.
Re: Depending on value, SOUND statement leaves port output high
Or if you do not want to use a capacitor, being brave enough, after the command use LOW to drive the pin at zero level.
Ioannis
Re: Depending on value, SOUND statement leaves port output high
I guess that "feature" worth mentioning in manual :D
Re: Depending on value, SOUND statement leaves port output high
Well, it shows a capacitor. So, you have to use a capacitor. It is that simple...
Ioannis