rvega / bbb-pru

A playground for using PRU units in the Beagle Bone Black.
5 stars 5 forks source link

Muxing code from PRU doesn't work #1

Closed eballetbo closed 9 years ago

eballetbo commented 9 years ago

Hi, many thanks for this code, I played with it and helped me a lot. I have some question about following statements, are you sure are working ?

bbb-pru/apps/gpio/pru.c

// See BeagleboneBlackP9HeaderTable.pdf from derekmolloy.ie 33 HWREG(0x44e10870) = 0x37;

// P9_13 pin as an input, with pullup. // See BeagleboneBlackP9HeaderTable.pdf from derekmolloy.ie 37 HWREG(0x44e10874) = 0x37;

// GPIO1[21](User led 0) as an output 40 HWREG(0x44e10854) = 0x0f;

I'm saying this because I had a problem with a custom app based on your apps, I'm trying to change the mux and doesn't work. With you example I did the simple change to replace line 40 for this new line:

HWREG(0x44e10854) = 0x07

Executed the host program and then read with devmem2

./devmem2 0x44e10854 /dev/mem opened. Memory mapped at address 0xb6fb7000. Value at address 0x44E10854 (0xb6fb7854): 0xF

As you can see mux register didn't change (0xf should be 0x7), any idea what could be wrong?

If you're interested I asked this question in e2e forum too:

https://e2e.ti.com/support/arm/sitara_arm/f/791/p/445028/1597702#1597702

Cheers, Enric

eballetbo commented 9 years ago

Found that is not possible change the mux through the PRU, :(

http://processors.wiki.ti.com/index.php/PRU-ICSS_FAQ#PRU_Memory_Access_questions

Q: Why can the PRU not edit pinmux settings?

The PRU does not have privileges to edit the pinmux or pad config settings in the device-level Control Module. However, the PRU can read these registers.

rvega commented 9 years ago

Hi @eballetbo, you are right, the PRU cannot alter the values in the pinmux registers. You have to do this through a device tree overlay (DTO). There are ways, however, to create "dynamic" DTOs that allow you to change the register values at runtime. See https://github.com/outer-space-sounds/beaglebone-pruio/ for an example (that's a library I created for using the PRUs from C and PureData programs and is more up to date than this repo).

eballetbo commented 9 years ago

Thank you for your answer, I'll take a look