Freqout and interupt


+ Reply to Thread
Results 1 to 4 of 4

Thread: Freqout and interupt2599 days old

  1. #1
    nuclear__
    Guest nuclear__'s Avatar

    0 Not allowed!

    Default Freqout and interupt

    Hi guys
    I tried to make a small musical instrument for fun.
    There are 3 analog channels that can read which button i press (one at a time).
    This is the simplest approach for me.
    An interrupt happens every about 13ms and i read the analog channels within the interrupt. I know its wrong etc but this uc will not do anything else.
    So if its literally wrong i don't care, if it will produce a problem then i do care.
    If i omit adin commands , sound is very clear.
    if i use them then there is some noise in the background, and a click whenever freqout starts again. This is the program.

    Code:
    Device = 16F873A
     
     
    Config FOSC_HS, WDTE_OFF, PWRTE_OFF, BOREN_ON, LVP_ON, CPD_OFF, WRT_OFF, DEBUG_OFF, CP_OFF
     
     
    Xtal 20
    Input PORTA
    Output PORTB
    Output PORTC
    Symbol T0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
    Symbol T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
    Symbol PEIE = INTCON.6 ' Peripheral Interrupt Enable
    Symbol GIE = INTCON.7  ' Global Interrupt Enable
    OPTION_REG = %0111 'prescaler 256 to timer0
    INTCON = %10100000 'interrupt on timer0
    ADCON0.0 =1
    ADCON0.7 =1
    ADCON0.6 =0
    ADCON1=%01000000
    CCP1CON=%1100
    Declare Adin_Res = 8
     
    'declare adit_tad =fosc
     
     
    Declare Adin_Stime = 1
     
    GIE = 1
    T0IE = 1
    Dim a As Byte
    Dim v As Bit
    Dim Volume As Byte
    Dim Freq As Word
    Dim Per As Word
    Dim Prescaler As Byte
    Dim Key0V As Byte
    Dim Key1V As Byte
    Dim Key2V As Byte
    Dim Key As Byte
    Prescaler=0
     
     
    On_Hardware_Interrupt GoTo Inthandler
     
     
    start:
    
     
    FreqOut PORTB.1,5000,key*10 
     
    
     
    GoTo start
     
    Inthandler:
            Context Save
    GIE = 0
          T0IF = 0
            Prescaler = Prescaler +1
            Select Prescaler 
                Case 10
                    Key0V  = ADIn 0
                Case 20
                    Key1V  = ADIn 1
                Case 30
                    Key2V  = ADIn 2
                Case 50    
                    Prescaler = 0
            EndSelect
    Key = Key0V + Key1V +Key2V
           Context Restore
    
    .
    i couldn't experiment with adin_tad command. Will it help me somehow?
    To eliminate clicks , i set the freqout time very high , and my purpose will be in the next step to stop freqout command while it works.
    ( long freqout and interupting it somehow rather than short freqout and serialy add freqout one after the other)
    My question is not very clear, i just want some opinions if there is a better way to do what i want , and if there is a way to short more the adin command.
    thanks
    I still have problem with this form, enter doesn't work for me (ie 10) and i must write these one notepad

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,748
    Thumbs Up
    Received: 51
    Given: 96
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: Freqout and interupt

    Freqout is probably the worst command to use an interrupt with.

    If you have to, write your a/d code long hand.

    Start the sample for the next reading as you leave the interrupt then read it on the next entry, this way you are not waiting for the conversion to be done with in the interrupt.

    Lastly your last line of code is going to give issues I would break it up, or at least check the ASM to check its not using any system variables.
    Tim

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    nuclear__
    Guest nuclear__'s Avatar

    0 Not allowed!

    Default Re: Freqout and interupt

    Thank you Tim, you are always there! Thats a good point to start searching.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    nuclear__
    Guest nuclear__'s Avatar

    0 Not allowed!

    Default Re: Freqout and interupt

    Hello
    my program now works fine. There is no delay and no noise if i split a/d commands in the interrupt.
    However adding more channels one problem occured. channel (an3) is not working. and there are some wrong readings.
    For example if one voltage on channel0 goes above 3V then channel1 reads about 200mV etc... i tried many different acq times with no change.
    However my main problem in an3.
    Is something obvious? Here is the piece of code that produces problem.
    .
    Xtal 20
    Input PORTA
    Output PORTB
    Output PORTC
    Symbol T1IF = PIR1.0
    Symbol T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
    Symbol PEIE = INTCON.6 ' Peripheral Interrupt Enable
    Symbol GIE = INTCON.7 ' Global Interrupt Enable
    Symbol GO = ADCON0.2 'START/DONE ADC BIT
    Symbol ADON = ADCON0.0
    INTCON = 000000 'interrupt on timer0
    ADCON0 = 000001
    ADCON1=000010 'channel 0 to 4 should work with 16f873a
    CCP1CON=00
    T1CON=111001
    PIE1.0=1 'enable timer1 interrupt
    start:
    T1CON.0 = 0
    GIE = 0
    'while Volume<32
    ' GoSub VolUp
    'wend
    ADCON0 = 129
    DelayUS 10
    GO = 1
    While GO = 1
    Wend
    Key0V = ADRESH '*************
    DelayUS 50
    ADCON0 = 137
    DelayUS 10
    GO = 1
    While GO = 1
    Wend
    Key1V = ADRESH '****************
    DelayUS 50
    ADCON0 = 145
    DelayUS 10
    GO = 1
    While GO = 1
    Wend
    Key2V = ADRESH '***************
    DelayUS 50
    ADCON0 = 153 'ANALOG3 NOT WORKING
    DelayUS 10
    GO = 1
    While GO = 1
    Wend
    Pitch1 = ADRESH '***************
    DelayUS 50
    ADCON0 = 161
    DelayUS 10
    GO = 1
    While GO = 1
    Wend
    Pitch2 = ADRESH '***************
    KeyW = Key0V + Key1V +Key2V
    SerOut PORTB.0,396,["note : ",Dec Note," k0v: ",Dec Key0V," k1v: ",Dec Key1V," k2v: ",Dec Key2V," keyW: ",Dec KeyW," P1: ",Dec Pitch1," P2: ",Dec Pitch2,13]
    If KeyW < 5 Then GoTo start
    Last edited by nuclear__; 21st April 2013 at 13:31.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. [SOLVED !] Freqout
    By nuclear__ in forum Proton Plus Compiler v3
    Replies: 7
    Last Post: 27th February 2013, 07:42
  2. FreqOut maximum frequency ?
    By fanie in forum Proton Plus Compiler v3
    Replies: 11
    Last Post: 3rd October 2011, 07:25
  3. [SOLVED !] 12F629 Interupt
    By bravo in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 18th February 2008, 05:14
  4. [SOLVED !] Counting - Interupt
    By Dave-S in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 6th September 2006, 15:02
  5. InfraRed 38.5k freqout like bs2
    By brown in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 24th May 2005, 18:16

Tags for this Thread

Posting Permissions

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