Need 4 modes with just 3 switches - need all modes to be selectable QUICKLY!


Closed Thread
Results 1 to 40 of 68

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Ok....experiencing a few diffs here.

    Basically I need IOC interupts (which I'm basing on a simpler cut down noobesque version of excellent Bruce's provided code)...but I also need timer interupts.

    My problem is that I get a boat load of errors when my program compiles when IOC & timer interupts are enabled together - what are the errors I hear you say? Well, I'm at work right now so can't cut/paste in what I'm seeing, but what I can say is that when I remove the timer interupt it compiles fine. Or when I remove the IOC interupt it compiles fine - only when both are enabled does it spew out heaps of errors during compilation.

    I also know that my overall code is fine - previously I was using the INT pin for interupts ...I was able to get both INT & Timer interupts enabled & working in that setup. So I'm figuring here that maybe this latest way of handling the switches - IOC interupts - are using up a whole lot more PIC resource than the previous way I was doing this? Maybe the combinbation of IOC interupts, timer interupts, plus my coat are pushing things too far?

    How to progress this?

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Ok, I'm home now.....here are the compile errors...

    Error[116] : Address label duplicated or different in second pass (_305AfterUserRoutine)
    Error[116] : Address label duplicated or different in second pass (_305NoInt)
    Error[116] : Address label duplicated or different in second pass (INT_EXIT)
    Error[116] : Address label duplicated or different in second pass (_290OverCREATE)
    Error[116] : Address label duplicated or different in second pass (L00001)
    Error[116] : Address label duplicated or different in second pass (L00002)
    Error[116] : Address label duplicated or different in second pass (L00003)


    .....and so on.

    Like I say I think it's to do with both interupt handlers being enabled?

    Which prompts me, how should two interupt handlers be coded wrt 'returns'. Should it look like this (wrt IOC Interupts, I've stripped it back to basics & removed the disabling/enabling in the interupt handler here.... just for easiness on the eye)

    Code:
    LED1   VAR  PORTB.1
    
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler  RABC_INT,  _Switch_Interupt,   PBP,  no
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    T1CON = $31                ; Prescaler = 8, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    @ INT_ENABLE RABC_INT 
    
    Main:
      PAUSE 1
    GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    
    '---[ioc Interupt Handler]------------------------------------------------------
    Switch_Interupt:
    TOGGLE LED2
    @ INT_RETURN

    Many thanks.
    Last edited by HankMcSpank; - 12th August 2010 at 18:52.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Is that the whole program?

    The errors seem to indicate there's another INT_CREATE somewhere.
    DT

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by Darrel Taylor View Post
    Is that the whole program?

    The errors seem to indicate there's another INT_CREATE somewhere.
    Hi, Darrel

    May be not it here, but ...

    Do you remember those errors also appeared in MPLAB 8.30 ( ? ), when PBP 2.50 was released ???
    ( was necessary to twist the Project/Build options/project/settings :" -ampasmwin -k#" )

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Do you remember those errors also appeared in MPLAB 8.30 ( ? ), when PBP 2.50 was released ???
    Thought about that, but it only affected DT_INTS-18.
    He's using -14 here.

    And as shown, it compiles without error here on a 16F690.
    PBP2.60A
    MPASM 5.36 from MPLAB 8.53, using MCS+.
    DT

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    And as shown, it compiles without error here on a 16F690.
    PBP2.60A
    MPASM 5.36 from MPLAB 8.53, using MCS+.
    Compiles fine here with MPLAB 8.53 ... IF Led2 is declared

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Ok, the plot thickens.

    Rightly or wrongly, I have somewhat bloated interupt handlers (BTW are there any guidelines/rules about how many lines, if statements etc you can lob in there?)

    For example, this is what I'm doing when an IOC occurs (this is my interupt handling routine)...

    Code:
    Switch_Interrupt:
    @ INT_DISABLE RABC_INT  ; Disable further IOC interrupts
    'DEBUG "Interrupt      On_status= ", dec on_status, " Mode =  ", DEC mode, " AGC Status= ", dec Agc_on_status, 13, 10
    
    IF sw1 = 0 THEN
    if on_status = 1 and mode = 1 then goto Switch_off
    Mode2_control  = 1		    
    Mode3_control  = 0         
    Mode4_control  = 1	        
    on_status = 1
    MODE =   1
    high GREEN_LED
    low RED_LED
    'IF debug_out = 1 then DEBUG "Sw1       On_status= ", dec on_status, " Mode =  ", DEC mode, 13, 10
    goto interrupt_end
    endif
    
    IF sw2 = 0 THEN
    pause 150
    if sw3 = 0 then
    Mode2_control  = 1		    
    Mode3_control  = 1         
    Mode4_control  = 0	       
    on_status = 1
    HIGH GREEN_LED
    low RED_LED
    MODE = 4
    'IF debug_out = 1 then DEBUG "Sw3&4     On_status= ", dec on_status, " Mode =  ", DEC mode, 13, 10
    goto interrupt_end
    endif
    endif
    
    IF sw2 = 0 THEN
    if on_status = 1 and mode = 2 then goto Switch_off
    Mode2_control  = 0		    '
    Mode3_control  = 0        
    Mode4_control 	= 1	        
    on_status = 1
    MODE = 2
    high GREEN_LED
    high RED_LED
    'IF debug_out = 1 then DEBUG "Sw2       On_status= ", dec on_status, " Mode =  ", DEC mode, 13, 10
    goto interrupt_end
    endif
    
    
    IF sw3 = 0 THEN
    if on_status = 1 and mode = 3 then goto Switch_off
    Mode2_control  = 1		    
    Mode3_control  = 1         
    Mode4_control 	= 1	        
    on_status = 1
    MODE = 3
    low GREEN_LED
    high RED_LED
    'IF debug_out = 1 then DEBUG "Sw3       On_status= ", dec on_status, " Mode =  ", DEC mode, 13, 10
    goto interrupt_end
    endif
    goto interrupt_end
    
    
    Switch_off:
        on_status = 0
        mode =  0
        low Green_LED
        low  Red_led
        Mode2_control = 1      '
        Mode3_control = 1   
        pwm_width = 0
        'IF debug_out = 1 then DEBUG "Switch_Off   On_status= ", dec on_status, " Mode =  ", DEC mode, 13, 10
    
    
    interrupt_End:
    IOC_FLAG = 0
    @ INT_ENABLE RABC_INT 
    'IF debug_out = 1 then DEBUG "Int_End   On_status= ", dec on_status, " Mode =  ", DEC mode, 13, 10
    @ INT_RETURN
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
    IF MODE = 4 THEN
         TOGGLE Green_LED
         TOGGLE RED_LED
         ENDIF
    @ INT_RETURN
    
    END

    If I comment out all the lines above starting "if debug_out = 1", my program then compiles fine! If I uncomment them I get 53 compilation erros (along the lines of what I posted earlier). But get this, while they're uncommented - which would normally give the errors - if in the main body of my program (not the interupt handlers), I then reduce the number of 'if' statements, like thus...

    (ignore the actual if/then statements - they're changed here to be easier on the eye & to get my point across)
    Code:
        IF Signal_In > target + 3 THEN goto a
        IF Signal_In > target + 2 THEN goto b
        IF Signal_In > target + 1 THEN goto c
        
        IF Signal_In < target - 3 THEN goto d
        IF Signal_In < target - 2 THEN goto e
        'IF Signal_In < target - 1 THEN goto f  ' program compiles even with my bloaty interupt if I comment out any one of these lines
        
        
        pause 20  
        GOTO START
        
        a:
        b:
        c:
        d:
        e:
       ' f:        ' program compiles even with my bloaty interupt if I comment out any one of these lines 

    So it seems to be a either combination of the amount of code I've lobbed into the interupt handler &/or the number of if statements I have in my main progam body.

    (before pouring scorn on the way I've approached this ...remember, I'm just a n00b - I work within the confines of my limited programming knowledge until a particular problem/situation forces me to learn something new!!)
    Last edited by HankMcSpank; - 12th August 2010 at 22:49.

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