Darrels interrupts and multiple SOUND statements, will it work?


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Darrels interrupts and multiple SOUND statements, will it work?

    Hi,
    2.2kHz (Output_x = 28835) should work. The higher you go the more jittery the output becomes.

    If you want to calculate the value to put in the Output_x variables at runtime (instead of using a lookup table or whatever) you can do it with Output_x = ( Frequency + ( Frequency ** 20353 ) ) where Frequency is a WORD containing the desired output frequency * 10, (4400 = 440.0Hz)

    It's not perfect but may be good enough.

    Let me know if you get around to trying it.

    /Henrik.

  2. #2
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: Darrels interrupts and multiple SOUND statements, will it work?

    What happens if I run this code say at 4mhz 16F870 ? there will be no output, frequency wont match, or sound will be breaking up?

  3. #3
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: Darrels interrupts and multiple SOUND statements, will it work?

    on 16F876A, gives error during compile on this:

    IPR1.1 = 1 ' TMR2 high priority

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


    Did you find this post helpful? Yes | No

    Default Re: Darrels interrupts and multiple SOUND statements, will it work?

    Gives same error on 12F1840.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Darrels interrupts and multiple SOUND statements, will it work?

    Hi,

    > What happens if I run this code say at 4mhz 16F870 ? there will be no output, frequency wont match, or sound will be breaking up?

    There's not enough time to actually execute the interrupt service routine before the timer fires another interrupt. The CPU will spend all of its time in the ISR, no time left for you to set the desired frequencies etc and the output frequenices will be wrong and...... Simply - It just won't work. You need 16MHz.

    > on 16F876A, gives error during compile on this:
    > IPR1.1 = 1 ' TMR2 high priority


    The 16F series doesn't have interrupt priorities, remove the line.

    > Gives same error on 12F1840.

    The 12F series doesn't have interrupt priorities, remove the line.

    /Henrik.

  6. #6
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: Darrels interrupts and multiple SOUND statements, will it work?

    Still does not compile on 16F876A -

    ASM ERROR:
    Symbol not previously defined (wsave), (ssave), (psave).

    Compile OK on 12F1840, but ASM warning - Found label after column 1. (Generate), Extraneous arguments on the line

  7. #7
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: Darrels interrupts and multiple SOUND statements, will it work?

    added this for 16F876A:

    Code:
    wsave VAR BYTE $20 SYSTEM
    ssave VAR BYTE $22 SYSTEM
    psave var byte $24 SYSTEM
    Have no idea why, but no more errors in compile, will try runtime shortly.

  8. #8
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: Darrels interrupts and multiple SOUND statements, will it work?

    It works, sort of (20mhz crystal 16F876A).

    If any channel duration has same value, these channels won't play.
    Also, playback duration is different each time, it might play 4 or 5 times same duration, then 2 times shorter duration, then again normal.
    It works properly only when value of output timings is first is the shortest, 2nd medium and 3rd - longest. If in reverse, it will only play last, short one.

Similar Threads

  1. Multiple IF THEN Statements: PIC16F84A
    By bob425 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th August 2012, 06:01
  2. Problem with multiple interrupts
    By aratti in forum General
    Replies: 7
    Last Post: - 2nd June 2009, 08:18
  3. Multiple IF-THEN statements
    By DavidK in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 20th June 2007, 18:28
  4. Handeling multiple Interrupts
    By BobSpencerr in forum General
    Replies: 15
    Last Post: - 1st March 2007, 01:12
  5. Multiple HW Interrupts
    By Radiance in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th August 2003, 22:35

Members who have read this thread : 0

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