HI,
I am trying to do LED toggle using PRU. My assembly code is
.origin 0
.entrypoint START
// GPIO3
#define GPIO3 0x481AE000
// GPIO5
#define GPIO5 0x48322000
#define GPIO_CLEARDATAOUT 0x190
#define GPIO_SETDATAOUT 0x194
#define GPIO_OE 0x134
START:
//set ARM such that PRU can write to GPIO
LBCO r0, C4, 4, 4
CLR r0, r0, 4
SBCO r0, C4, 4, 4
//base magic number for PWM
MOV r5, 250
//r6 is period (250 << 20)
LSL r6, r5, 20
//r5 is on_period (250 << 19) for 50% duty
LSL r5, r5, 19
// Configure as GPIO OUT
MOV r3, GPIO3 | GPIO_OE
LBBO r2, r3, 0, 4
CLR r2, 2
SBBO r2, r3, 0, 4
//writes 7 to 8 user LEDs to turn on (no external hardware necessary)
PWM_ON:
MOV r2, 3<< 6
MOV r3, GPIO3 | GPIO_SETDATAOUT
SBBO r2, r3, 0, 4
MOV r4, 0
//wait until on_period is reached before turning off
//or wait until period to turn back on again
DELAY:
ADD r4, r4, 1
QBEQ PWM_ON, r4, r6
QBNE DELAY, r4, r5
//writes 7 to 8 user LEDs to turn off
PWM_OFF:
MOV r2, 3 << 6
MOV r3, GPIO3 | GPIO_CLEARDATAOUT
SBBO r2, r3, 0, 4
QBA DELAY
Could you please correct me, if anything wrong in above code.
GPIO LED PINS are
GPIO3_18
GPIO3_7
GPIO3_8
GPIO5_10
GPIO5_11
GPIO5_12
GPIO5_13
GPIO5_14
On Host(ARM) Side Linux is running.
Regards,
Yuvaraj