Menu

Interrupt error with GCB v0.97.01

Help
viscomjim
2017-09-24
2017-09-24
  • viscomjim

    viscomjim - 2017-09-24

    I wrote a program about a year ago and it compiled and functioned perfectly. I can't remember what version of GCB I wrote it in, but it was maybe 2 or 3 versions ago. Anyway, I just downloaded and installed v0.97.01. I loaded the same exact program, no changes at all, and it won't compile due to this error...

    on interrupt PortBChange call SwCheck   'interrupt when switch goes low
    

    I am using this...

    #chip 16F1825, 20
    #config OSC = HS, Pllen = OFF
    

    Since I had the original hex file, I was able to load it into the pic using the IPE and the program runs perfectly. I am thinking since it compiled before and the hex still runs just fine, maybe there was a change on how the interrupt is handled now??? But at this point, I can't make any changes to the program since I am now getting this error.

    The program is a several hundred lines long, but here is the jist of how I am listening to the switches... Again, this all worked perfectly, I just can't compile it now with new version. I hope I am just missing something easy...

    Thanks for any and all help! Also, where can I download the v0.98 (the newest) GCB.

    #chip 16F1825, 20
    #config OSC = HS, Pllen = OFF
    
    #define ModeSw1 portA.2     'Pin 11 A.2 - Mode Switch 1
    #define ModeSw2 portA.3     'Pin 4 A.3 - Mode Switch 2
    
    dir ModeSw1 in
    dir ModeSw2 in
    
    set IOCAN2 on
    set IOCAN3 on
    
    on interrupt PortBChange call SwCheck   'interrupt when switch goes low
    
    MAIN:
    stuff
    stuff
    stuff
    goto MAIN
    
    '*********************** SWITCH INTERRUPT *******************
    sub SwCheck
    if ModeSw2 = 0 then
      ClrAll
      Mode2Sub
    end if
    if ModeSw1 = 0 then
      ClrAll
      Mode1Sub
    end if
    end sub
    
    '*********************** Mode1Sub *******************
    sub Mode1Sub
    set IOCAN2 off        '<<<<< Turn off interrupt
    ButtonCount = 0
    do while ModeSw1 = 0
    wait 10 ms
    buttoncount +=1
    if buttoncount > 150 then '<<<<< LongPress Happened
      if LongPressA = 1 then  '<<<<< Toggle Mode
        LongPressA = 2
      else
    LongPressA = 1
      end if
      do while ModeSw1 = 0  '<<<<< Flash to indicate LongPress
    pulseout LED, 50 ms
    wait 50 ms
    loop
      for Ll = 1 to 10      '<<<<< Flash a little more
    pulseout LED, 50 ms
    wait 50 ms
      next Ll
      EPWrite 2, LongPressA
      IntHit = 1        '<<<<< Interrupt happened Flag
      goto GetOutA        '<<<<< Leave after toggle
    end if
    loop
    
    if buttoncount > 3 and LongPressA = 1 then
    ModeA = ModeA + 1
    if ModeA = 10 then ModeA = 1
    IntHit = 1      '<<<<< Interrupt happened Flag
    EPWrite 0, ModeA
    goto GetOutA
    end if
    if buttoncount > 3 and LongPressA = 2 then
      ModeB = ModeB + 1
      if ModeB = 6 then ModeB = 1
      IntHit = 1
      EpWrite 1, ModeB
    end if
    GetOutA:
    set IOCAF2 off      '<<<<< Reset interrupt flag
    set IOCAN2 on     '<<<<< Turn interrupt back on
    end sub
    
    '*********************** Mode2Sub *******************
    sub Mode2Sub
    set IOCAN3 off
    ButtonCount = 0
    do while ModeSw2 = 0
    wait 10 ms
    buttoncount +=1
    loop
    
    if buttoncount > 3 and LongPressA = 1 then
    ModeA = ModeA - 1
    IF ModeA = 0 THEN ModeA = 9
    IntHit = 1      '<<<<< Interrupt happened Flag
    EPWrite 0, ModeA
    goto GetOutB
    end if
    if buttoncount > 3 and LongPressA = 2 then
      ModeB = ModeB - 1
      if ModeB = 0 then ModeB = 5
      IntHit = 1
      EPWrite 1, ModeB
    end if
    GetOutB:
    set IOCAF3 off      '<<<<< Reset interrupt flag
    set IOCAN3 on     '<<<<< Turn interrupt back on
    end sub
    
     
  • kent_twt4

    kent_twt4 - 2017-09-24

    Yea that would a sort blanket error now with 98, not sure exactly when it started. It used to be PortBChange covered PortB, PortA and who knows. Now you have to be specific. So using PortAChange should let you further develop the older program. The new 18f1825.dat file states PortAChange, and PortChange are available for Interrupts.

     
  • Anobium

    Anobium - 2017-09-25

    Support Kent.

    Change to the correct IOC Port - there are not IOC events raised on PortB. The options are shown below, PortA0..5. None of PortB

    IOCAP,0
    IOCAP,1
    IOCAP,2
    IOCAP,3
    IOCAP,4
    IOCAP,5

    If PortBChange worked in the past then that was an error. That error has be removed - sorry.

    Hopefully, all we be good then.

     
  • William Roth

    William Roth - 2017-09-27

    When the compiler returns an interrupt error such as :

    16F1825x.gcb (5): Error: Invalid interrupt event: PORTBCHANGE
    

    .
    . You can open the chip datafile for that particular chip and look at the [interrupts] section. This section will tell you what interrupts are supported by GCB and and what registers/bits are used. Below is the [interrupts] section for the 16F1825 in Ver 97.xx Datfile.

    'GCBASIC/GCGB Chip Data File
    'Chip: 16F1825
    'Generated 22/1/2017
    'Format last revised: 14/11/2009

    [Interrupts]
    ADCReady:ADIE,ADIF
    CCP1:CCP1IE,CCP1IF
    CCP2:CCP2IE,CCP2IF
    CCP3:CCP3IE,CCP3IF
    CCP4:CCP4IE,CCP4IF
    Comp1Change:C1IE,C1IF
    Comp2Change:C2IE,C2IF
    EEPROMReady:EEIE,EEIF
    ExtInt0:INTE,INTF
    OscillatorFail:OSFIE,OSFIF
    PORTAChange:IOCIE,IOCIF
    PortChange:IOCIE,IOCIF

    SSP1Collision:BCL1IE,BCL1IF
    SSP1Ready:SSP1IE,SSP1IF
    Timer0Overflow:TMR0IE,TMR0IF
    Timer1Gate:TMR1GIE,TMR1GIF
    Timer1Overflow:TMR1IE,TMR1IF
    Timer2Match:TMR2IE,TMR2IF
    Timer4Match:TMR4IE,TMR4IF
    Timer6Match:TMR6IE,TMR6IF
    UsartRX1Ready:RCIE,RCIF
    UsartTX1Ready:TXIE,TXIF

     
  • viscomjim

    viscomjim - 2017-09-28

    Thank you everyone for the info. Now I know to check the data file. Not sure why this worked very well using the portBchange in past versions. I switched to portAchange and all is well in my world.

    I have to say, the effort that goes into this is amazing to me. I try and preach GCB to as many of my nerdly friends as possible, because it just keeps gettting better and better. I have so many projects working due to the great work that has gone into this. I just want to share my appreciation to Evan, Hugh, and all the people on this excellent forum that make this wonderful project work so damn well. I tip my hat!!!!!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.