This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using PRU as GPI

Hi,

I have connected some of my general purpose descrete inputs to PRU0_R31 ( pins 9-15 and 23-29). I have gone through the example PRU_gpiotoggle. Still I don't have an idea of how to modify this program to read GPIs as said above. Can somebody guide me.

I am using AM1808EVM.

Regards,

Kalimuthu C

  • Hi Kalimuthu,

    To adapt the PRU_gpiotoggle example to read GPIs, you will need to:

    1.  Update the pinmux.p (and pinmux_reset.p) to configure the pinmuxing for the GPI pins you require.  Refer to pinmux_pru_config.txt for the assembly commands for different PRU GPI/O pins.

    2.  In the main assembly file (i.e. PRU_gpioToggle.p), you would monitor the R31 pins.  Here is one example of how to read the value on PRU R31 pin 9 and store it in r0 for future use:  
            LSR     r0, r31, 9
            AND    r0, r0, 1
    Note the PRU core that this code is loaded and executed on determines whether it is reading PRU0_R31 or PRU1_R31.  Depending on your application, you may also find the following PRU commands useful:  WBS, QBBC, QBBS.  See the PRU Assembly Instructions wiki for additional details.

    3.  Update PRU_gpioToggle.c per your application needs.

    Regards,
    Melissa

  • Hi Melissa,

    Done. Thank you. 

    ( Being new to Linux, ARM, 32bit and PRUSS, I have taken little more time.)

    I've used some other GPIO (GP5[3], GP5[4]) also by writing directly to OUT_DATA45 register in PRUSS. Is it advisible or we have to use the GPIO driver only?

    Regards,

    Kalimuthu C

  •  

    Hi Kalimuthu,

    It should be okay to write to the chip's GPIOs using the PRUSS.  However, in the context of Linux where you have a GPIO driver which manages GPIO resources, it would be good to allocate the GPIO pin via the OS API and pass it to PRU to prevent any conflict which may arise.

    Also keep in mind that since the GPIO control registers are bank specific, the OS running on the ARM and PRU may simultaneously write to some of the registers.  The GPIOs provide set/clear registers to maintain data integrity within the hardware. These registers must be used to toggle GPIO instead of the raw set/clear register.

    Regards,

    Melissa