Announcement

Collapse
No announcement yet.

PmmC update 25 -> 26 : I2C1_Close no longer working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PmmC update 25 -> 26 : I2C1_Close no longer working

    Hello,

    After I updated the DIABLO16 PmmC version from 25 to 26 the function I2C1_Close() no longer working, but give an address trap.

    Even a following simple test fails:

    Code:
    #platform "uLCD-43DT"
    
    func main()
    print("Hello World");
    
    I2C1_Close();   // Cause address trap
    
    repeat
    forever
    
    endfunc
    It works without problem on PmmC25.

    Best regards,
    Mris

  • #2
    In some ways it's odd that this did not happen in R25.

    If you I2C1_Close() without having first done I2C1_Open() the I2C pins are undefined.

    Or are you trying to say something else?
    Mark

    Comment


    • #3
      Hello,

      calling I2C_Close before anything comes from an example program delivered to me in 2013 for uLCD-43PT: AR1020Repeat.4dg.
      It starts looks like:

      Code:
      #platform "uLCD-43PT"
      #inherit "..\\Daveprog\\AR1020.inc"
      #constant time 5
      var combuf[1000] ;
      
      
      func main()
      var i, j, STATUS, touchx, touchy , acctm ;
      
      I2C_Close();
      pause(100);
      I2C_Open(I2C_SLOW);
      pause(100);
      
      if(AR2010(ENABLE_TOUCH, 0)==OK) // disable touch
      print("\nTouch Enabled\n");
      else
      print("\nTouch Enabled FAILED\n");
      endif
      print("Touch and hold Now\n") ;
      
      ...
      This I2C is used by the touch controller, so it should be initialized before.

      Now I use this code part for uLCD-43DT and not uLCD-43PT:

      Code:
      I2C1_Close();
      pause(100);
      I2C1_Open(I2C_SLOW);
      pause(100);
      It worked since then for both uLCD-43DT and uLCD-43PT.
      Last edited by mris99; 12 July 2021, 07:13 PM.

      Comment


      • #4
        Just checked and the TouchcalD.inc which is delivered with the latest Workshop do also the following:

        Code:
        func main()
        
        ...
        
        repeat
        I2C1_Close();
        pause(100);
        I2C1_Open(I2C_SLOW,PA13,PA12);
        pause(100);
        
        //if(AR2010(DISABLE_TOUCH, 0)==OK) // disable touch
        // print("\nTouch Disabled\n");
        //else
        // print("\nTouch Disable FAILED\n");
        //endif
        until (AR2010(DISABLE_TOUCH, 0)==OK); // disable touch at the AR1020 level
        print("\nTouch Disabled\n");
        
        ...
        There is no I2C1_Open() before the I2C1_Close() in the main function.

        No wonder that the touch calibration is not working with R26 from the workshop any more, it cause an ADDRESS TRAP.

        Comment


        • #5
          It works on Picaso because the I2C pins are fixed/defined.

          Diablo came after Picaso and hence touchCalD descended from the Picaso version. The potential error of the spurious close was not found at that time.

          Attached is a fixed TouchCalD.inc, please replace the current one in C:\Users\Public\Documents\4D Labs\4DUpdates\Utils
          Attached Files
          Mark

          Comment


          • #6
            Thank you, it works that way. Can you explain what the Rev2 means and why the SCL pin defined as ALL?

            Code:
            if (Rev2)
            I2C1_Open(I2C_SLOW,ALL,PA12);
            else
            I2C1_Open(I2C_SLOW,PA13,PA12);
            endif

            Comment


            • #7
              That's for the future. It's related to potential Rev2 gen4 boards,


              Actually for the moment comment that out and just use

              I2C1_Open(I2C_SLOW,PA13,PA12);

              The Rev2 'identification' code can mistake a Rev1.x board for a Rev2 one
              Mark

              Comment


              • #8
                Thank you for the explanation and support. It works fine without initial I2C1_Close.

                Comment


                • #9
                  Dear Mris99. I have just experienced an ADRESS TRAP, and luckily I found your post. I solved my problem by removing the initial I2C1_Close.
                  But - how did you find that it was this code that made the ADRESS TRAP?
                  Did you find it by the adresse numer or did you just comment out your code until success?

                  Just want to know if I get another ADRESS TRAP :-)

                  Thanks in advance and regards

                  Poul



                  Comment


                  • #10
                    You can work it out using the .map file in the .4dwork folder created when compiling your project.
                    Mark

                    Comment

                    Working...
                    X