Depending on value, SOUND statement leaves port output high


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default 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?

  2. #2
    Join Date
    Aug 2011
    Posts
    412


    Did you find this post helpful? Yes | No

    Default 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.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default 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

  4. #4
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Depending on value, SOUND statement leaves port output high

    I guess that "feature" worth mentioning in manual

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default 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

Similar Threads

  1. Replies: 11
    Last Post: - 19th June 2014, 10:00
  2. Replies: 11
    Last Post: - 13th January 2013, 10:25
  3. Replies: 5
    Last Post: - 17th May 2012, 10:14
  4. 16F883 and Problems with HIGH statement
    By aaanekre in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th October 2009, 01:09
  5. Duplicating port input to port output
    By lwindridge in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th April 2004, 21:43

Members who have read this thread : 12

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts