Today 10:59
Forum: Proton Plus Compiler v3
Starter: Henk57
Views: 0
Replies: 2
Go to last post By: Lester
Yesterday 20:59
Forum: Website / Forum Issues
Starter: Lester
Views: 0
Replies: 10
Yesterday 20:40
Forum: New devices and techniques
Starter: normnet
Views: 861
Replies: 2
+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Correct use of bit names23 days old

  1. #1
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,639
    Thumbs Up
    Received: 61
    Given: 18
    Total Downloaded
    2.27 GB

    0 Not allowed!

    Default Correct use of bit names

    So I have the following: -

    Code:
    Symbol RBIF     = INTCON.0  ' Port B Interrupt-On-Change (IOCx) Interrupt Flag bit
    Symbol INT0IF   = INTCON.1  ' INT0 External Interrupt Flag bit
    Symbol TMR0IF   = INTCON.2  ' TMR0 Overflow Interrupt Flag bit
    Symbol RBIE     = INTCON.3  ' Port B Interrupt-On-Change (IOCx) Interrupt Enable bit
    Symbol INT0IE   = INTCON.4  ' INT0 External Interrupt Enable bit
    Symbol TMR0IE   = INTCON.5  ' TMR0 Overflow Interrupt Enable bit
    Symbol PEIE     = INTCON.6  ' Peripheral Interrupt Enable bit
    Symbol GIE      = INTCON.7  ' Global Interrupt Enable
    
    INTCON  = %00010000
    Now if in main routine I do: -

    Code:
    INT0IE = 0
    nothing happens, but if I do: -

    Code:
    INTCON = %00000000
    everything works as expected.

    The INT0IE does not turn green once type it.
    Regards

    Joseph

  2. #2
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,639
    Thumbs Up
    Received: 61
    Given: 18
    Total Downloaded
    2.27 GB

    0 Not allowed!

    Default Re: Correct use of bit names

    Did another test.

    Code:
    INTCON.4 = 0
    Do not work as well. Could it be that INTCON must be write all at once?
    Regards

    Joseph

  3. #3
    Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    387
    Thumbs Up
    Received: 20
    Given: 2
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: Correct use of bit names

    Other than perhaps the additional spaces (if in your actual code) used to align the = INTCON.x text I cannot see where the problem could lie as the following works for me (12F675)

    Code:
    '~~~ Configure Interrupts ~~~
    INTCON = $00        'GIE, PIE and Port Change Interrupt disabled & Port Change Interrupt flag (INTCON.0) cleared
        Symbol GPIF = INTCON.0  ' Port Change Interrupt Flag
        Symbol GPIE = INTCON.3  ' Port Change Interrupt Enable
        Symbol PEIE = INTCON.6  ' Peripheral Interrupt Enable
        Symbol GIE = INTCON.7   ' Global Interrupt Enable
    PIE1 = $00                  ' ADC peripheral Interrupt Disabled
    IOC = $08                   'Enable Interrupt on Change for GP3 (PortB.3) only 
    INTCON = $88        'GIE and Port Change Interrupt enabled, Port Change Interrupt Cleared
    
    '~~~ Configure ADC ~~~
    ADCON0 = $81                'ADC on, Left Justified, Channel 0
    Symbol Go_Done  = ADCON0.1  'Alias ADC Go_Done bit
    ANSEL = $11                 'Fosc/8 = 2uS TAD (1.76us min), AN0 = Analogue, AN3:AN1 = Digital
    
     
    GoTo Start  'Jump over ISR & Subroutines
    
    '*********************
    '* Interrupt Handler *
    '*********************
    PORT_IOC:           'Interrupt Service PortB Interrupt on Change (PortB.3 when switch SW1 pressed)
    Context Save
    Clrwdt              'Clear the Watchdog Timer
    GIE = 0             'Disable All Interrupts
    If GPIF = 1 Then    'Check that Port Change Interrupt Occured
        Repeat DelayMS 10 : Until PORTB.3 = 1   'Wait until swith released
    
    Dummy = PORTB       'Read Port to remove Mismatch condition
    INTCON = $00        'Clear All Interrupts
    GPIF = 0            'Clear Port change interrupt flag again - just to be sure
    
    Program = ~Program  'Change Program from $00 to FF and via versa
    Dummy = PORTB       'Re-Read Port restore default condition for mosmatch (PORTB.3 High)
    INTCON = $88        'Re-enable GIE and Port Change Interrupts 
    Else
    GIE = 0             'Disable All Interrupts
    INTCON = $00        'Clear All Interrupts
    INTCON = $88        'Re-enable GIE and Port Change Interrupts 
    EndIf
    Context Restore
    As for the highlighting, I can not remember how that is handled but it may have something to do with the bit names either not being included or different to those you are using in either the bit name or PPI files but without knowing what device you are using I am unable to check that or that or reproduce the issue.

  4. #4
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,639
    Thumbs Up
    Received: 61
    Given: 18
    Total Downloaded
    2.27 GB

    0 Not allowed!

    Default Re: Correct use of bit names

    Thanks Stephen for the reply,

    Even if I do not disable the interrupt, i.e. GIE = 0, like you did, INTCON = $00 register will stop the `external interrupt', the one I want to disable. However, if I try to write only one bit, in my case INTCON.4 = 0 the external interrupt on RB.0 does not stop.

    So I am sticking with writing the whole INTCON at once rather than INTCON.4 alone.

    Regarding the highlighting I used the PDS BNF tool from hadv215 to generate the bit names and works great.

    I use that type of alignment to make code more friendly to read, never had an issue till now.
    Last edited by joesaliba; 21st November 2017 at 18:31.
    Regards

    Joseph

  5. #5
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,037
    Thumbs Up
    Received: 85
    Given: 19
    Total Downloaded
    927.31 MB

    0 Not allowed!

    Default Re: Correct use of bit names

    which device are you using?
    There may be a mixup between IOC and INT

    I have never encountered problems clearing or setting an individual bit in INTCON

  6. #6
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,639
    Thumbs Up
    Received: 61
    Given: 18
    Total Downloaded
    2.27 GB

    0 Not allowed!

    Default Re: Correct use of bit names

    18F26K22. I cannot understand me too.

    And it seems only INTCON.4, (INT0IE), as clearing or setting GIE or PEIE there is no problem at all.
    Regards

    Joseph

  7. #7
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,037
    Thumbs Up
    Received: 85
    Given: 19
    Total Downloaded
    927.31 MB

    0 Not allowed!

    Default Re: Correct use of bit names

    Check the bnf and look for intcon. Are the bits correct?
    Furthermore check your code. It wouldn't be the first time when a "0" and a "O" or "o" are mixed up

  8. #8
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,639
    Thumbs Up
    Received: 61
    Given: 18
    Total Downloaded
    2.27 GB

    0 Not allowed!

    Default Re: Correct use of bit names

    Yes harm, all bits are ok.

    In fact if I change the INTCON from INTCON = %00010000 to INTCON = %00000000 the external interrupt on INT0 stops.

    Then I have this: -

    Code:
    Symbol INT0IE = INTCON.4  ' INT0 External Interrupt Enable bit
    If I do INT0IE = 0 or INTCON.4 = 0 the external interrupt does not stop.

    I will read, modify and write the register if I need to as a work around.

    I also noted that rewriting the INTCON register stops the ISR, i.e.: - rewriting INTCON = %00010000
    Regards

    Joseph

  9. #9
    Developer Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,245
    Thumbs Up
    Received: 231
    Given: 87
    Total Downloaded
    1.50 GB

    0 Not allowed!

    Default Re: Correct use of bit names

    Take a look at the device's .def file. You'll see all the bit names that are easy to use and remember. They also highlight green when used within a program. The .def files can be found in "C:\Program Files (x86)\ProtonIDE\PDS\Includes\Defs"

    For example:

    ; INTCON Bits
    $define INTCONbits_RBIF INTCON.0
    $define INTCONbits_INT0IF INTCON.1
    $define INTCONbits_TMR0IF INTCON.2
    $define INTCONbits_RBIE INTCON.3
    $define INTCONbits_INT0IE INTCON.4
    $define INTCONbits_TMR0IE INTCON.5
    $define INTCONbits_PEIE_GIEL INTCON.6
    $define INTCONbits_GIE_GIEH INTCON.7
    $define INTCONbits_INT0F INTCON.1
    $define INTCONbits_T0IF INTCON.2
    $define INTCONbits_INT0E INTCON.4
    $define INTCONbits_T0IE INTCON.5
    $define INTCONbits_PEIE INTCON.6
    $define INTCONbits_GIE INTCON.7
    $define INTCONbits_GIEL INTCON.6
    $define INTCONbits_GIEH INTCON.7

    In your program you can use something like:

    Set INTCONbits_GIE

    etc...
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  10. #10
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,639
    Thumbs Up
    Received: 61
    Given: 18
    Total Downloaded
    2.27 GB

    0 Not allowed!

    Default Re: Correct use of bit names

    Thanks Les. That is super easy how to set or clear.

    For my problem, I did some further tests and I test for the INTCON.4 bit if it is changed. It seems to be changed however, once cleared, the pic still `accepts' external interrupt on INT0. Must be a device problem as clearing the INTCON.4 should stop interrupt on INT0.

    I took another approach to solve my problem I was having. Thanks everyone for your inputs.
    Regards

    Joseph

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Proton24 Compiler bit names
    By RGV250 in forum Proton 24
    Replies: 1
    Last Post: 2nd January 2016, 12:21
  2. multiline bit names
    By Puffeltje in forum Wish List / Product Feedback
    Replies: 0
    Last Post: 3rd August 2013, 19:50
  3. Hrsin timeout not correct
    By grahamg in forum Proton Plus Compiler v3
    Replies: 12
    Last Post: 11th October 2012, 18:19
  4. Timing not correct
    By Dave-S in forum Proton Plus Compiler v3
    Replies: 10
    Last Post: 9th February 2011, 23:21
  5. Please Correct me
    By willim in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 7th June 2007, 10:04

Members who have read this thread since 13th December 2017, 11:02 : 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