Reading GPIO input from mem in PRU (BBB)

Hi

I found the following code and although it compiles the example app
never exits while waiting for HALT. And after that all other example
apps no longer work.

#define GPIO0 0x44e07000
#define GPIO1 0x4804c000
#define GPIO2 0x481ac000
#define GPIO_OE 0x134
#define GPIO_DATAIN 0x138

MOV r3, GPIO1 | GPIO_OE

LBBO r2, r3, 0, 4

SET r2, 12 // set bit 12

SBBO r2, r3, 0, 4

MOV r3, GPIO1 | GPIO_DATAIN

LBBO r2, r3, 0, 4 // Store register contents into r2

     // r2 contains of all GPIO1, so now you can inspect the value of
bit 12 as desired

HALT

can anyone tell what’s wrong or another way of doing this?
/Jacob