Other ports use for interrupt


Today 08:22
Forum: Proton Plus Compiler v3
Starter: Valter
Views: 0
Replies: 2
Today 07:54
Forum: The Lounge
Starter: shantanu@india
Views: 0
Replies: 16
Yesterday 17:27
Forum: SnapShot
Starter: towlerg
Views: 0
Replies: 53
Yesterday 15:57
Forum: Proton Plus Compiler v3
Starter: gtv_pic
Views: 0
Replies: 20
Yesterday 14:55
Forum: Proton Plus Compiler v3
Starter: kuhrig
Views: 0
Replies: 1
+ Reply to Thread
Results 1 to 6 of 6

Thread: Other ports use for interrupt397 days old

  1. #1
    19roland70
    Guest 19roland70's Avatar

    0 Not allowed!

    Default Other ports use for interrupt

    I have an electronic circuit with 3 pushbuttons and a display.
    I would replace the pushbuttons for an Rotary encoder.
    My problem is that the ports B.0 and B.1 are already in use and I can't change the pcb
    below a part of the program.
    Code:
    Device = 16F628A   
    Config XT_OSC , WDT_OFF, PWRTE_ON, LVP_OFF, BODEN_OFF, MCLRE_OFF
      
    All_Digital TRUE              ;Alle ingangen digitaal  
    Xtal 4
    '---------------------------LCD--------------------------------  
    Declare  LCD_DTPin = PORTB.0
    Declare     LCD_RSPin = PORTB.4
    Declare  LCD_ENPin = PORTA.3
    Declare  LCD_Interface = 4  '4-bit Interface
    Declare  LCD_Lines = 2
    Declare  LCD_Type = ALPHA
    Symbol SDA = PORTA.1           'I2C op poort a1   
    Symbol SCL = PORTA.0           'I2C op poort a0
    Symbol LED = PORTA.2           'ledverl. op poort a2
    Symbol ToetsHoger = PORTB.7
    Symbol ToetsLager = PORTB.5 
    Symbol ToetsSet = PORTB.6 
    Dim FREQ_step As Word           'Frequency step
    Dim FREQ_khz As Word            'Frequency Khz
    Dim FREQ_mhz As Word            'Frequency Mhz
    Dim FREQ As Word
    Dim TSA_Uitlezen As Word
    Dim ADRESS As Byte              'TSA5511 i2c adres
    Dim LO As FREQ.LowByte
    Dim HI As FREQ.HighByte
    EData 2160,2160,2160
    PORTA = %00000000               ;PORTA uitgangen bij opstart een laag niveau
    TRISA = %11111011               ;PORTA.2 is een uitgang voor de LED
    PORTB = %00000000               ;PORTB uitgangen bij opstart een laag niveau
    TRISB = %11111111               ;PORTB. is een uitgang voor de LED    
     
    Cls
    lus:
    High LED
    Print At 1,1, "FM Test"
    Print At 2,1, "W 7 testset"
    DelayMS 1000
    ADRESS = $C2                    'TSA5511 in adres
    FREQ_step = ERead 02            'geheugen lezen voor frequentie in EData
    If FREQ_step > 0 Then TSA
    '-----------------------------------------------------
    Freq_set:
    FREQ = FREQ_step
    I2COut SDA,SCL,ADRESS,[HI,LO,$8F,$10]        '$8F varicap drive uit 
    FREQ_khz = (FREQ_step*10/2)//100
    FREQ_mhz = (FREQ_step*10/2)/100
     
    Print At 1,1, "Set FM"
    Print At 2,1,  Dec FREQ_mhz, ",", Dec FREQ_khz
    DelayMS 200
    If ToetsHoger = 1 Then Freq_up
    If ToetsLager = 1 Then Freq_down
    If ToetsSet = 1 Then Freq_save
    GoTo Freq_set
    
    '-----------------------------------------UP_freq----------------------------
    Freq_up:
    FREQ_step = FREQ_step + 1 'step 5
    If FREQ_step > 2160 Then FREQ_step = 1750
    GoTo Freq_set
    '----------------------------------------DOWN_freq--------------------------
    Freq_down:
    FREQ_step = FREQ_step - 1 'step 5
    If FREQ_step < 1750 Then FREQ_step = 2160
    GoTo Freq_set
    '--------------------------data opslaan---------------------------
    Freq_save:
    EWrite 02, [FREQ_step]
    DelayMS 50
    How can I change this ,so I can Use an Rotary encoder.

  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
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    429
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    2.33 GB

    0 Not allowed!

    Default Re: Other ports use for interrupt

    How about using a Timer interrupt to read the port pins say every 100mS?

    Within the interrupt do something like this...
    Code:
    Rotary_Data_Old = Rotary_Data_New   'Make previous new encoder data value read the new old value
    Rotary_Data_New = Portx & %00001110  'Read new rotary value masking off bits not used for the encode (Set bits required to 1, other bits to 0)
    
    Select Rotary_Data_New     'Assign (NOT convert) binary encoder values to sequential decimal values 1 to 6 as the encoder values will be in a grey scale sequence 
             Case = %00000010
                Rotary_Data_New = 1
             Case = %00000100 
                Rotary_Data_New = 2
       'Repeat for as many values as required
    EndSelect
    I presume this is your current button code...

    Code:
    If ToetsHoger = 1 Then Freq_up
    If ToetsLager = 1 Then Freq_down
    If ToetsSet = 1 Then Freq_save
    If so then change it to something like...
    Code:
    If Rotary_Data_Old = 6 & Rotary_Data_New = 1 then        'Up direction loop around
       Freq_up 
    ElseIF Rotary_Data_Old = 1 & Rotary_Data_New = 6 then    'Down direction loop around
       Freq_down 
    ElseIf Rotary_Data_New > Rotary_Data_Old                 'Up direction turn
       Freq_up
    ElseIf Rotary_Data_New < Rotary_Data_Old                 'Down direction turn
       Freq_down
    EndIf
    Hopefully that will do what you want.

  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
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,976
    Thumbs Up
    Received: 183
    Given: 168
    Total Downloaded
    3.60 GB

    0 Not allowed!

    Default Re: Other ports use for interrupt

    B7 is IOC. Personally I never use pins that are part of ICSP, but thats just me.

    I can't remember how I did this last time but its something like generate an interupt on one pin and read the other to sus the direction. Maybe this will help, it uses pin that you have here
    George.

  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
    Junior Member flosigud's Avatar
    Join Date
    Oct 2013
    Posts
    59
    Thumbs Up
    Received: 10
    Given: 6
    Total Downloaded
    1.48 GB

    0 Not allowed!

    Post Re: Other ports use for interrupt

    You can use IOC to read pins 4 and 5 on portb. That won't interfere with ICSP. There is no setup apart from port settings. RBIE =1 starts the interrupt and the handler can be like this:

    Code:
    If RBIF = 1 Then                        ' On RBIF interrupt
        RBIF = 0
        Swapf PORTB,WREG
        bNew = WREG & 3
    EndIff
    Flosi Guđmundsson
    Reykjavík

  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.

  9. #5
    Junior Member flosigud's Avatar
    Join Date
    Oct 2013
    Posts
    59
    Thumbs Up
    Received: 10
    Given: 6
    Total Downloaded
    1.48 GB

    0 Not allowed!

    Default Re: Other ports use for interrupt

    I must have been out of my mind when I wrote the above comment. Of cource you have to set up the interrupt or at least decide on which pin it operates. This is how I did it on some ocasion.
    Code:
        Symbol NOT_RBPU = INTCON2.7
        IOCB = $F0                                 ' PortB 7-4 used
        NOT_RBPU = 0                            ' PortB pullups on
    Flosi Guđmundsson
    Reykjavík

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

  11. #6
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,158
    Thumbs Up
    Received: 360
    Given: 130
    Total Downloaded
    1.53 GB

    0 Not allowed!

    Default Re: Other ports use for interrupt

    A has been stated above, the interrupt on change is extremely useful. Once the interrupt has fired, the interrupt handler can detect which pin it was, of the four, that caused the interrupt.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  12. 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. Incrementing ports
    By Richard in forum Proton Plus Compiler v3
    Replies: 10
    Last Post: 19th May 2009, 07:42
  2. Replies: 12
    Last Post: 18th January 2009, 22:59
  3. Ports
    By DanStory in forum Proton Plus Compiler v3
    Replies: 9
    Last Post: 4th September 2007, 08:01
  4. More serial ports
    By galeforce9 in forum The Lounge
    Replies: 7
    Last Post: 31st August 2007, 21:34

Members who have read this thread since 10th March 2019, 03:43 : 0

Actions :  (Set Date)  (Clear Date)

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

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