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.
Tool/software: TI C/C++ Compiler
Following is a snippet I use to get PRU going:
PRU0_DisableAndReset();
PRU0_Load(PRUSandbox_image_0, (sizeof(PRUSandbox_image_0)/sizeof(int)));
PRU0_Run();
// for (crc=0;crc<15000;crc++);
while (!PRU0_IsRunning());
I am using CCS v8.2 for debugging indirectly via shared memory as well as PRU registers. The problem is that without some delay after PRU0_Run(), the code doesn't execute. Is there some initialization step with PRU settings I am missing? In the PRU code itself, I'm using whatever the compiler generated by default.
I'm not sure which software you mean, but the below is what I am dealing with:
Code Composer Studio v8.2.0.00007
PRU compiler is "ti-cgt-pru_2.3.1"
Linked with --zero_init=off. (so the hex utility generate code array only)
Hex array of unsigned int numbers representing code generated - which is pasted into host code and transferred to PRU.
The sequence of calls to load and enable PRU is as follows.
int main(void) {
uint16 crc, i, j, k;
uint8 * bptr;
uint8 far *cptr;
InitSharedRAM();
InitMsgIDs();
/* Turning on the PRU */
PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_PRU, PSC_POWERDOMAIN_ALWAYS_ON,
PSC_MDCTL_NEXT_ENABLE);
PRU0_DisableAndReset();
PRU0_Load(PRUSandbox_image_0, (sizeof(PRUSandbox_image_0)/sizeof(int)));
PRU0_Run();
for (crc=0;crc<5000;crc++);
while (!PRU0_IsRunning());
The related code is as follows:
#define PRU_CONTROL_ALLDISABLE (0x00000000u)
#define PRU_CONTROL_COUNTENABLE (0x00000008u)
#define PRU_CONTROL_ENABLE (0x00000002u)
#define PRU_CONTROL_RUNSTATE (0x00008000u)
#define PRU0_PROG_RAM_START (0x01C38000)
#define PRU1_PROG_RAM_START (0x01C3C000)
#define PRU0_DATA_RAM_START (0x01C30000)
#define PRU1_DATA_RAM_START (0x01C32000)
void PRU0_DisableAndReset(void){
/* Count enable (bit 3) and enable (bit 1) set to zero (disable) */
/* Soft reset (bit0)*/
HWREG(SOC_PRUCORE_0_REGS) = PRU_CONTROL_ALLDISABLE;
}
/* Enables the PRU */
void PRU0_Run(void){
HWREG(SOC_PRUCORE_0_REGS) |= PRU_CONTROL_COUNTENABLE;
HWREG(SOC_PRUCORE_0_REGS) |= PRU_CONTROL_ENABLE;
}
/* checks if the PRU is running */
bool PRU0_IsRunning(void) {
return ((HWREG(SOC_PRUCORE_0_REGS)&PRU_CONTROL_RUNSTATE)
== PRU_CONTROL_RUNSTATE);
}
/* Loads binary code into the PRU's RAM */
void PRU0_Load(const uint32* pruCode, uint32 codeSizeInWords){
//void PRU0_Load( uint32* restrict pruCode, uint32 codeSizeInWords){
uint32 i;
uint32 * pruIram;
pruIram = (uint32 *) PRU0_PROG_RAM_START;
for(i=0; i<codeSizeInWords; i++)
{
pruIram[i] = pruCode[i];
}
}
/* checks if the PRU is running */
bool PRU0_IsRunning(void) {
return ((HWREG(SOC_PRUCORE_0_REGS)&PRU_CONTROL_RUNSTATE)
== PRU_CONTROL_RUNSTATE);
}