Today 09:04
Forum: Website / Forum Issues
Starter: Lester
Views: 0
Replies: 1
Today 08:48
Forum: Proton Plus Compiler v3
Starter: IstvanK
Views: 0
Replies: 6
Go to last post By: Lester
Today 08:44
Forum: Test Postings
Starter: Lester
Views: 0
Replies: 3
Yesterday 22:15
Forum: The Lounge
Starter: towlerg
Views: 0
Replies: 0
+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: 3.6.0.3 and HIGHLOW_TRIS_REVERSE ??12 days old

  1. #11
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,361
    Thumbs Up
    Received: 49
    Given: 124
    Total Downloaded
    2.37 GB

    0 Not allowed!

    Default Re: 3.6.0.3 and HIGHLOW_TRIS_REVERSE ??

    automatically changed when you either input or output to a port
    It is changed automatically, but by the compiler.

    The issue here is that the code generated by the compiler does the TRIS first (so whatever is in the output latches of the bits that are now outputs appears on the port buffers). For example High Portn,n - where Portn,n is currently an input and the latch has 0. When it is TRIC it goes from tri-state to 0 then the port data is written it goes to 1. The effect will be that the port will float then go lo then go hi when spyder wants it to float then go hi.

    @spyder0069 I know it's a pain to change a working program but the built-in one wire commands will make your program more maintainable and less sensitive to small compiler changes.

    The other alternative which I would not recommend, is to install multiple versions of the compiler and use the latest for new projects and the earlier one for legacy stuff.
    Last edited by towlerg; 6th December 2017 at 04:16.
    George

  2. #12
    Administrator John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,895
    Thumbs Up
    Received: 78
    Given: 25
    Total Downloaded
    1.37 GB

    0 Not allowed!

    Default Re: 3.6.0.3 and HIGHLOW_TRIS_REVERSE ??

    OK , I understand the issue more clearly now and can see the problem - but not a solution. We'll have to wait for the guru methinks.
    John

  3. #13
    Senior Member AlbertoFS's Avatar
    Join Date
    Apr 2005
    Posts
    584
    Thumbs Up
    Received: 76
    Given: 2
    Total Downloaded
    1.93 GB

    0 Not allowed!

    Default Re: 3.6.0.3 and HIGHLOW_TRIS_REVERSE ??

    Hi all,
    I have tested with the PDS version 3.6.0.3 and the same thing happens.
    Since this command has no subroutine, I do not know how to #Disable it. We would have to ask Les.

    Sometimes, when you want to protect a code against the variation of the compiler, you better write your commands with the preprocessor.
    I've tried this, and it seems to work. But I do not know why the compiler does not give an error.
    If so, replace the Low/High commands with _Low/_High.

    This is an example of a library to replace the Low/High command.

    Then choose at the beginning of the program the option:
    $define __HighLow_Tris_Reverse On
    Or
    $define __HighLow_Tris_Reverse OFF

    The Macro:
    Code:
        $define Low(pPort,pPin)          '
        $if __HighLow_Tris_Reverse = Off '
        Output pPort.pPin                '
        Clear pPort.pPin                 '
        $else                            '
        Clear pPort.pPin                 '
        Output pPort.pPin                '
        $endif   
    
        $define High(pPort,pPin)         '
        $if __HighLow_Tris_Reverse = Off '
        Output pPort.pPin                '
        Set pPort.pPin                   '
        $else                            '
        Set pPort.pPin                   '
        Output pPort.pPin                '
        $endif
    The code:
    Code:
        $define __HighLow_Tris_Reverse On
    '    $define __HighLow_Tris_Reverse OFF
        Low(PORTB,0)
    
        High(PORTB,1)
    Regards
    [U]73's de Alberto ea3agv[/U]

  4. #14
    Developer Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,247
    Thumbs Up
    Received: 234
    Given: 87
    Total Downloaded
    1.50 GB

    0 Not allowed!

    Default Re: 3.6.0.3 and HIGHLOW_TRIS_REVERSE ??

    There's a typo in the reserved words section of the manual.

    It's Declare TRIS_Reverse = On or Off or True or False or 1 or 0

    I thought I'd added this to the manual a few years ago, but looking at it now, and it's not in there. It may have been when I was updating things and my hard drive crashed a few years ago.

    What it does is reverse the sequence used by the High and Low commands. For example, the asm default of the compiler for High PORTB .0 is:

    bcf TRISB ,0
    bsf PORTB ,0

    Which alters the TRIS first, then the PORT (LAT if using 18F devices).

    With the declare set to on, the compiler produces the asm:

    bsf PORTB ,0
    bcf TRISB ,0

    Which alters the PORT (LAT for 18F devices), then the TRIS.

    On modern devices it, generally, makes no difference what is manipulated first, but on some of the older devices it was required.
    Last edited by Les; 6th December 2017 at 12:22.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  5. #15
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,361
    Thumbs Up
    Received: 49
    Given: 124
    Total Downloaded
    2.37 GB

    0 Not allowed!

    Default Re: 3.6.0.3 and HIGHLOW_TRIS_REVERSE ??

    There you go spyder, the horses mouth.
    George

  6. #16
    Member spyder0069's Avatar
    Join Date
    May 2002
    Posts
    123
    Thumbs Up
    Received: 1
    Given: 0
    Total Downloaded
    91.79 MB

    0 Not allowed!

    Default Re: 3.6.0.3 and HIGHLOW_TRIS_REVERSE ??

    WooHoo! Thanks Les! That did the trick. :^)

    This is a 18f2620 running on the internal oscillator at 8mhz for reference.

    I do use the oread and owrite commands (ds18b20 in parasite mode) but have some of the init sequence and holding the line high during conversion using high/low commands. I also have the whole routine for a sensirion sht-15 sensor written with these so it was important to my code.

    Thank you all for your suggestions!

    -Dion

Thread Information

Users Browsing this Thread

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

     

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