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.

  • Resolved

C6748 using PRU for GPIO

Intellectual 860 points

Replies: 1

Views: 905

I am trying to get PRU work for toggling some pins. For testing purpose I have attached LEDs and logic analyzer probes to these pins.

My other post about why I would like to use PRU for GPIO bitbanging can be found here: http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/115/p/295398/1031085.aspx#1031085

I made a new post because my issue with PRU is too specific.

PRU Software Development Package v1.03 is downloaded from here: http://www.ti.com/tool/sprc940 

Here is snippet from PRU_gpioToggle example that is modified to set PRU pins PRU0_R30[18], PRU0_R30[19], PRU0_R30[20] to 1.

PRU_gpioToggle.p

.origin 0
.entrypoint GPIO_TOGGLE
#include "PRU_gpioToggle.hp"

GPIO_TOGGLE:
LDI global.count, GPIO_BIT
LDI global.delay, 0x0
gpioSet 18
gpioSet 19
gpioSet 20
//LOOP:
// gpioSet global.count
//LOOP2:
// ADD global.delay, global.delay, 0x1
// QBGT LOOP2, global.delay, 0xFF
//
// gpioClr global.count
// ADD global.count, global.count, 0x1
// QBGT LOOP, global.count, GPIO_COUNT
HALT

PRU_gpioToggle.hp

.macro gpioSet
.mparam bitNum
SET r30, r30, bitNum
.endm
// gpioClr : Clear one of the PRU gpio pins through R30
//
// Usage:
// gpioClr bitNum
//
// Clears r30 bit specified in bitNum.
//
.macro gpioClr
.mparam bitNum
CLR r30, r30, bitNum
.endm
#define GPIO_BIT 6
#define GPIO_COUNT 0x8

// ***************************************
// * Global Structure Definitions *
// ***************************************
.struct Global
.u16 count
.u16 delay
.ends

// ***************************************
// * Global Register Assignments *
// ***************************************
.assign Global, r2, *, global

Output from pasm: PRU_gpioToggle_bin.h

const unsigned int PRUCode[] = 
{
0x24000682,
0x240000c2,
0x1f12fefe,
0x1f13fefe,
0x1f14fefe,
0x2a000000
};

Snippet for running PRU

PRU_disable();
PRU_load(0, (Uint32*)PRUCode, (sizeof(PRUCode)/sizeof(Uint32)));
PRU_run(0);
if (PRU_waitForHalt(0,-1) == E_PASS) {
i = 0;
}
else {
i = 1;
}
PRU_disable();
while (1) {
}

I can see that PRU_waitForHalt return with E_PASS, however none of the LEDs lit. Strangely if HALT is removed and reassembled it still return with E_PASS.

Is this correct way to turn on PRU0_R30[18] SET r30, r30, 18? What out DSP pinmux?

Are memory macro definitions correct for C6748?

#define PRU0_DATA_RAM_START (0x01C30000)
#define PRU0_PROG_RAM_START (0x01C38000)
#define PRU1_DATA_RAM_START (0x01C32000)
#define PRU1_PROG_RAM_START (0x01C3C000)
#define PRU_DATA_RAM_SIZE (0x200)
#define PRU_PROG_RAM_SIZE (0x1000)

It would be really helpful to get some hints how to debug it further. Asm code is very simple, there must be somekind of configuration issue or misunderstanding about PRU GPIO module.

Andres

  • Problem was with pinmuxing. DSP must set PRU pins pinmuxing before giving control to PRU. I found this information from here http://caxapa.ru/thumbs/319913/PRUSS_Training_Slides.pdf page 16.

    PRU_R30[18], PRU_R30[19], PRU_R30[20] pins must be set in PINMUX0. With CCS 5.3 those registers are shown as Reserved, however they are really for PRU0 R30 pins.

    From C:\Program Files\Texas Instruments\pdk_C6748_2_0_0_0\C6748_StarterWare_1_20_03_03\include\hw\hw_syscfg0_C6748.h following defines can be found:

    #define SYSCFG_PINMUX0_PINMUX0_19_16_PRU0_R30_18 (0x00000002u)
    #define SYSCFG_PINMUX0_PINMUX0_7_4_PRU0_R30_19 (0x00000004u)
    #define SYSCFG_PINMUX0_PINMUX0_3_0_PRU0_R30_20 (0x00000004u)

    It now works for me.

    Andres

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.