Using iMx6 and pinMuxing

Discussion in 'UDOO 101' started by Buldres, Aug 14, 2014.

  1. Buldres

    Buldres New Member

    Joined:
    Aug 14, 2014
    Messages:
    2
    Likes Received:
    0
    Hi,
    I'm kind of new with my Udoo, but I've been a lot in the uC thing.
    I was wondering if there is an efficient way of controlling and muxing pin and set alternate mode with the iMx6 chip.
    From what I've heard and read, it needs to be kernel-compiled again each time you want to change settings and so on. Is that true?
    Can someone relate their experience of using input/output pin in c / c++ / java on the linux side without having to sketch on the arduino side?
    Also, is there a more efficient way than writing into a file to set direction / pin mode?
    I've been searching trough documentations and tutorials for my answer, and I fear the worst for most of them, so here I am asking them on the forum.


    thank you
     
  2. peter247

    peter247 New Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    I think you may be confused about Pin Muxing .

    Pin Muxing is a way to turn a gpio pin into a special function like , serial , i2c , spi .
    Which I can`t see a problem of setting which functions you need and compiling than into the kernel I sticking to that.
    But when you set that pin into it`s function you just can`t use it as a gpio pin.
     
  3. Buldres

    Buldres New Member

    Joined:
    Aug 14, 2014
    Messages:
    2
    Likes Received:
    0
    I do know what pin muxing is.
    What I don't know is why should I bother with kernel compiling every time I want to change pin mode.
    If Udoo is a dev board, then it shouldn't be that hard to change pin mode.
    for example, in on project I need can port to talk with automotive application, and another one a I2C communication, I don't want to jump back and recompile kernel every time I switch project.
    In certain projects I would like to have PWM active and some other, use those pin as GPIO, but don't want to sketch a new arduino program, for each of them so I think using the internal iomux is the way to go, unless kernel compilation is necessary every time I want to change pin mode.
    Is that less confusing?
     
  4. fetcher

    fetcher Member

    Joined:
    Mar 9, 2014
    Messages:
    166
    Likes Received:
    20
    You can switch pin-muxing states on the fly by writing directly to i.MX6 registers. See my earlier post at the end of this thread,

    http://www.udoo.org/forum/pwm-pins-mx6-udoo-quad-udoobuntu-t1585.html

    for an example of changing a pin from GPIO to PWM mode using register pokes.

    For things that require an actual kernel driver, such as UARTs, you still need one recompile at the beginning to enable all these various peripheral modules you might possibly want to use. There's no harm in having them all enabled and mapped to /dev nodes, even if some aren't always connected to pins. The driver bindings are done in linux/arch/arm/mach-mx6/board-mx6_seco_UDOO.c -- e.g.


    static inline void mx6q_seco_UDOO_init_uart(void) {
    imx6q_add_imx_uart(0, NULL);
    imx6q_add_imx_uart(1, NULL);
    imx6q_add_imx_uart(2, NULL); // added UART3 aka /dev/ttymxc2
    imx6q_add_imx_uart(3, NULL);
    imx6q_add_imx_uart(4, NULL); // added UART5 aka /dev/ttymxc4
    }

    The three i.MX6 I2C buses are enabled already, if I remember correctly. /dev/i2c-0 is the main one available on Arduino pins headers... others show up on the Camera, LCD, and HDMI connectors.

    The Freescale CPU's various SPI buses probably need to be set up in this *UDOO.c file too if you want to use them, but I haven't yet worked with that bus under Linux to know specifics.
     

Share This Page