Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08 Oct 2008 09:51 AM by  physicseng
GPIO read and write with C++
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages
Fred Dyer
New Member
New Member
Posts:


--
26 Oct 2007 10:36 AM
    Hi - I need to write to and read from the GPIO lines using C++. How is this done?

    Also, are pull-up resistors needed on these outputs/inputs? What is the high level voltage? I am assuming 5 Volt?

    Thanks! - Fred
    kurtl@logicpd.com
    New Member
    New Member
    Posts:


    --
    26 Oct 2007 12:45 PM
    Fred,
    For the IO characteristics for each pin on the CPU, please refer to the i.MX31 Datasheet from Freescale.
    Here is a direct link:
    http://www.freescale.com/...t/MCIMX31.pdf?fpsp=1
    Chapter 4 has the electrical characteristics. As you can see, the max on any and all pins is 3.3V. Most pins, however, operate at 1.8V so keep this in mind while designing your product. If you are using the i.MX31 module, the i.MX31 SOM-LV Hardware Specification on the LogicPD website has a pin out table that indicates which I/O are at 1.8V, 2.7V or 3.3V at power on reset.
    http://www.logicpd.com/auth/downloads/i.MX31/

    -K
    Fred Dyer
    New Member
    New Member
    Posts:


    --
    26 Oct 2007 02:13 PM
    Thanks, Kurt! Could you tell me if my C code is correct? I'm trying to activate GPIO pin 0, which is connected to an LED, so I believe if I'm doing it correctly then it should turn off the LED. (Do you know of any sample code for accessing the GPIO lines?)

    // sw_mux_ctl_gpio1_0_gpio1_1_gpio1_2_gpio1_3
    PEGULONG *sw_mux_ctl = (PEGULONG *) 0x43FAC14C

    //DR
    PEGULONG *dataRegister = (PEGULONG *)0x53FCC000;

    // GDIR
    PEGULONG *directionRegister = (PEGULONG *)0x53FCC004;

    //PSR
    PEGULONG *padStatusRegister = (PEGULONG *)0x53FCC008;


    *sw_mux_ctl &= 0x00000000; // set pads to GPIO mode
    *directionRegister |= 0x0000000F;// set GDIR to output
    *dataRegister &= 0x11111110; // zero the last 4 bits
    *dataRegister |= 0x1; // write 1 in bit 0 to turn on GPIO line 0
    juanluna
    New Member
    New Member
    Posts:


    --
    31 Jul 2008 02:18 PM
    Hi Fred, I'm trying to activate GPIO pin 0 too, and I would like to ask you what methods, library or functions are you using to access and modify the physical addresses?

    Regards
    physicseng
    New Member
    New Member
    Posts:


    --
    08 Oct 2008 09:51 AM
    Posted By juanluna on 31 Jul 2008 2:18 PM
    Hi Fred, I''m trying to activate GPIO pin 0 too, and I would like to ask you what methods, library or functions are you using to access and modify the physical addresses?

    Regards




    Altho they name them uP_GPIO_0 and uP_GPIO_1, they are really on MCU1_7 and MCU1_8, which are also named CAPTURE and COMPARE on the schematic.
    You are not authorized to post a reply.