Announcement

Collapse
No announcement yet.

Programming with GPIO's

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Programming with GPIO's

    Hi working through the application notes, doc Visi GPIO PINS at page 10 if provides sample code to activate gpio pins

    I have tried naming the pin GPIO_1, IO_1, GPIO1_PIN, IO1_PIN

    The compiling error message is

    Error: 'INPUT' not found (line 517 file:SpeedlessTest6.4dg)
    Error: context error for unknown 'INPUT' (line 517 file:SpeedlessTest6.4dg)


    Here is the code i have

    func main()
    gfx_ScreenMode(LANDSCAPE) ;
    disp_SetReg(SSD1963_SET_ADDRESS_MODE, 0x09); // flip vertically from landscape only, different values can flip Portrait, Portrait_R and Landscape_R

    pin_Set(INPUT, GPIO1_PIN)

    repeat
    if(pin_Read(GPIO1_PIN == 1)
    print("ON \r");
    gfx_CircleFilled(120,200,100,RED);
    else
    print("OFF\r");
    gfx_CircleFilled(120,200,100, DARKRED);
    endif
    forever



  • #2
    Put the cursor under pin_set and press F1
    Mark

    Comment


    • #3
      Thanks for that reference however i still cannot see what i am doing wrong as i am following the instructions as per example in screen shot.

      Also not sure if its relevant i am using 4D UPA for the pins
      Attached Files
      Last edited by SpeedlessAustralia; 15 August 2020, 01:10 PM.

      Comment


      • #4
        also on the section re pins its what i have highlighted in screenshot below a typo
        Attached Files

        Comment


        • Juniel Cruz
          Juniel Cruz commented
          Editing a comment
          Good day!

          Thanks for notifying us about this. We'll take note of this for the next document update.

          I'm not sure if you've noticed this already but I might as well point it out. See that there is no INPUT keyword used for the first parameter of the function pin_Set.

          The issue you first had is as the error message said "Error: 'INPUT' not found"

        • Juniel Cruz
          Juniel Cruz commented
          Editing a comment
          In your case, you'd want to use PIN_INP

      • #5
        Hi just to put you in the picture what i am ultimate wanting to achieve is when the digital input on gpio1 is high then the screen displays form1 and when its low it displays form0 being the default screen

        Comment


        • #6
          Hi

          Can you please confirm for me that i am FINALLY on the right track ??

          i needed to assign the values for the mode and pin number not the "text description"

          so to assign the pin as input its mode value is 0 as per that table
          the pin number needs to gust reference the number as a value not the "GPIO1"


          pin_Set(0, 1); // set pin 1 as input ( 0 = input mode and 1 is the pin number )
          pin_LO(1); // set the digital input 1 to default as low

          repeat
          if(pin_Read(1) == 0)
          print("ON \r");
          gfx_CircleFilled(120,200,100,RED);
          else
          print("OFF\r");
          gfx_CircleFilled(120,200,100, DARKRED);
          endif
          forever
          Last edited by SpeedlessAustralia; 15 August 2020, 01:36 PM.

          Comment


          • #7
            Hi,

            You don't need to use the values. The pin names and modes are predefined so you only need to use the right keywords.

            Click image for larger version

Name:	diablo16_pins.PNG
Views:	59
Size:	204.6 KB
ID:	73200


            For pins, you can refer to the column headings (PA0 to PA15).
            For modes, you can refer to the row headings (PIN_INP, PIN_INP_HI etc).

            Best Regards,
            Juniel Cruz

            Comment


            • #8
              To add to this, if you are using the 4D-UPA, and you are using the names off the bottom of the UPA itself for the GPIO, in the code - then this is not correct.
              As Juniel said above, the pin names for the functions are in reference to the processor. The GPIO names on the bottom of the 4D-UPA are generic as there are multiple devices that can use those GPIO pins, PICASO, Diablo16, etc. You need to look at the Datasheet for the 4D-UPA also, and cross reference what the GPIO name is on the 4D-UPA vs what pin it goes to on the Diablo processor.

              So if you are trying to use GPIO1 on the bottom of the 4D-UPA, then the Diablo16 pin is PA3 as per the table from the 4D-UPA datasheet.

              Click image for larger version

Name:	4D-UPA-Pinout.png
Views:	80
Size:	21.5 KB
ID:	73202
              James

              Comment


              • #9
                Wow ok have all that, would never jade figured out that on my own much appreciated

                Comment

                Working...
                X