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.

TMS320C6748: PRU interrupt clear?

Part Number: TMS320C6748

I am attempting to run a simple test loop but it is obvious that I am not clearing the interrupts because the PRU cycles at full speed. The code to set up the PRU is

    /* Waking up the PRU instance. */
    PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_PRU, PSC_POWERDOMAIN_ALWAYS_ON,
                         PSC_MDCTL_NEXT_ENABLE);
    HWREG(SOC_PRUCORE_0_REGS) = 0; // halt PRU0
    HWREG(SOC_PRUINTC_0_REGS + PRU_INTC_CHANMAP0) = 3;
    HWREG(SOC_PRUINTC_0_REGS + PRU_INTC_CHANMAP1) = 12;
    HWREG(SOC_PRUINTC_0_REGS + PRU_INTC_HOSTMAP0) = 0x100;
    HWREG(SOC_PRUINTC_0_REGS + PRU_INTC_STATCLRINT0) = -1;
    HWREG(SOC_PRUINTC_0_REGS + PRU_INTC_HSTINTENIDXSET) = 0;
    HWREG(SOC_PRUINTC_0_REGS + PRU_INTC_HSTINTENIDXSET) = 1;
    HWREG(SOC_PRUINTC_0_REGS + PRU_INTC_GLBLEN) = 1;
    HWREG(SOC_PRUINTC_0_REGS + PRU_INTC_ENABLESET0) = 0x1008;
    iram = SOC_PRUCORE_0_IRAM;
    for(i=0; i<PRULENGTH; i++)
        iram[i] = pru0_code[i];
    HWREG(SOC_PRUCORE_0_REGS) = 3; // enable PRU0

The code that loads (and runs) on the PRU is this:

*
*  Simple test of INTC and timer 0 interrupt
*  will eventually use with SPI to collect data
*
	.global main
	.text

main:
	ldi r1, 0x4024         ; pointer to STATIDXCLR
	ldi r2, 3              ; timer interrupt index
	ldi r3, 30             ; bit to test in r31
	ldi r4.w2, 0x01c2      ; high address of timer 0
	ldi r4.w0, 0x0044      ; low address of timer 0 INTCTLSTAT
	ldi r5, 2              ; value to write to INTCTLSTAT
start:
	qbbc start, r31, r3    ; is bit 30 set in r31?
	sbbo &r1, r2, 0, 4     ; write 3 to STATIDXCLR
	sbbo &r4, r5, 0, 4     ; write 2 to INTCTLSTAT
	xor  r30.b3, r30.b3, 4 ; toggle GPIO 6-8
	jmp  start             ; and wait for next timer interrupt

	.end

When I halt the processors I can clear the interrupt by writing directly to INTCTLSTAT, but the PRU does not seem to execute this. What am I doing wrong? Mike

Edit addition:

When I write 0xffffffff to location 0x1c34200 (STATSETINT0) I  see 0xffffffff result (all interrupts set).  When I then write 0xffffffff to location 0x1c34280 (STATCLRINT0) location 0x1c34200 goes to 0xff7fffff instead of 0x00000000.  Is there something wrong with the PRU, or is this a good clue to some other register not being set properly???

  • Hi Mike,

    I've forwarded this to the SW experts. Their feedback should be posted here.

    BR
    Tsvetolin Shulev
  • Thanks. I have found a work around by ignoring the INTC and just looking at the Timer0 INTCTLSTAT directly. It would be nice to know if I just missed setting up some register, or if the INTC is broken.
    Mike
  • Mike,

    I think you have your registers mixed up in arguments for the assembly code. It is always a good idea to write your PRU code in C first and get it working, then optimize the assembly to get it working minimally, if needed.

    It sounds like really simple code, but try it in CCS by single stepping and manually changing values in registers to see what really works. Our documentation for the assembly syntax is not always the clearest to me, so I try to keep small example code around that I can either reference my own comments or test simple syntax questions.

    Regards,
    RandyP