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.

PRU code not running

Genius 5820 points

First of all: this is obviously NOT a Starterware question since it does not support PRU. Here no Starterware is involved, code mentioned below is PRU-C-Code or plain, bare-metal C-code!

I'm doing some first experiments with PRU0 and TI's PRU-C-compiler but without success. PRU-initialisation seems to be OK but the code is not running. My PRU example code does nothing more than blink with an LED that is connected to a GPO:

1
2
3
4
5
6
7
8
9
10
int main()
{
   for (;;)
   {
       HWREG(SOC_GPIO_1_REGS + GPIO_SETDATAOUT)=LED_STOP_BIT;
       __delay_cycles(100000000);
       HWREG(SOC_GPIO_1_REGS + GPIO_CLEARDATAOUT)=LED_STOP_BIT;
       __delay_cycles(100000000);
   }
}

Pin-mux and configuration of output LED_STOP_BIT was done in main-application before PRU-code was started. GPIO-addrsses accessed within this code are the normal ones of main address space.

Next PRU is enabled, powered and clocks are turned on so that PRU_CTRL-register shows 0x0001. Then data and text generated with PRU-C-compiler are loaded into appropriate memory areas:

1
2
memcpy((void*)PRU0IRAM_PHYS_BASE,textbuf,textlen);
memcpy((void*)DATARAM0_PHYS_BASE,databuf,datalen);

Finally PRU_CTRL-register is set to 0x00000002 and afterwards show 0x00008003 - means PRU should be enabled and running. Nevertheless my LED is not blinking.

Any ideas what could be missing?

  • How are your I/O pins pinmuxed?

  • The pin that corresponds to LED_STOP_BIT is pin-muxed as GPIO and configured as output. Pinmuxing and configuration was done out of the main-application, not from within the PRU-code which should be OK?

    When I toggle the output out of my main-application it works well so I assume its configuration is correct.

     

  • Hi,

    To access SOC_GPIO outside PRU_ICSS, you need to enable OCP master port access

    http://processors.wiki.ti.com/index.php/PRU-ICSS_FAQ#Q:_Why_does_my_PRU_firmware_hang_when_reading_or_writing_to_an_address_external_to_the_PRU_Subsystem.3F

  • OK, I'm now writing 0x00000005 to address 0x4a326000+0x0004 which should disable standby-modes and enable OCP master port - but PRU code is still not running. Any other ideas?

  • You can connect to PRU using JTAG and see disassembly window or read status register to see where program counter is?

  • OK, I made some progress. My PRU initialisation code works, but only when I step through it in debugger. Running the same without the debugger-caused delays does not work. That's my current initialisation code:

       HWREG(SOC_PRM_PER_REGS)|=0x00000002;
       HWREG(SOC_PRM_PER_REGS)&=0xFFFFFFFD;
    
       HWREG(SOC_CM_PER_REGS+CM_PER_PRU_ICSS_CLKCTRL)=0x00000002;
       HWREG(SOC_CM_PER_REGS+CM_PER_PRU_ICSS_CLKSTCTRL)=(CM_PER_PRU_ICSS_CLKSTCTRL_OCP_GCLK|CM_PER_PRU_ICSS_CLKSTCTRL_IEP_GCLK);
    
       HWREG(PRUSS_CFG_BASE+PRUSS_CFG_BASE_SYSCFG)=0x00000005; // no stand-by modes and OCP master port enabled
    
       memcpy((void*)PRU0IRAM_PHYS_BASE,textbuf,textlen);
       memcpy((void*)DATARAM0_PHYS_BASE,databuf,datalen);
       HWREG(PRU0CONTROL_PHYS_BASE+PRU_PHYS_BASE_CTRL)|=0x00000002;
    

    It seems there is a delay necessary somewhere or I have to wait until one of the registers signals "ready" somehow. I have the feeling it has to do something with 0x00000005 written into PRUSS_CFG_BASE+PRUSS_CFG_BASE_SYSCFG but this method to write into the register does not solve the problem:

       do
       {
          HWREG(PRUSS_CFG_BASE+PRUSS_CFG_BASE_SYSCFG)=0x00000005; // no stand-by modes and OCP master port enabled
       }
       while ((HWREG(PRUSS_CFG_BASE+PRUSS_CFG_BASE_SYSCFG) & 0x00000005)==0);
    

    Any ideas what is wrong in this initialisation?

  • I solved it by adding a short delay before this line of code:

    HWREG(PRUSS_CFG_BASE+PRUSS_CFG_BASE_SYSCFG)=0x00000005

    I don't know if it is a good solution but it works.