cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to generate an interrupt request using PIT in SPC560B54L5 Microcontroller. My program is not working. Can you please suggest me the flow of the program and how to write an ISR Handler?

Pooja WANI
Associate II
 
This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
1 ACCEPTED SOLUTION

Accepted Solutions
zambrano.luigi
Senior III

Hi,

let me suggest you to install SPC5Studio tool. It is a free of charge tool that you can download from the ST web site. SPC5Studio includes a lot of examples that show how to initialize the SPC56/57/58 cores and the related IPs. It includes also an application (SPC560Bxx_RLA PIT Test Application for Discovery) for the Bolero B Discovery board (based on SPC560B54L5) that uses two channels of the PIT1. In particular, the callback fuctions related to the interrupts will blink two leds on the board.

Best Regards,

Luigi

View solution in original post

7 REPLIES 7
zambrano.luigi
Senior III

Hi,

let me suggest you to install SPC5Studio tool. It is a free of charge tool that you can download from the ST web site. SPC5Studio includes a lot of examples that show how to initialize the SPC56/57/58 cores and the related IPs. It includes also an application (SPC560Bxx_RLA PIT Test Application for Discovery) for the Bolero B Discovery board (based on SPC560B54L5) that uses two channels of the PIT1. In particular, the callback fuctions related to the interrupts will blink two leds on the board.

Best Regards,

Luigi

Thank You.

I am not getting the exact flow of the program. I am trying it on my own at Register Level without using In-built Libraries.

I have configured the PIT0 registers and written Exception Handler accordingly. However, it's not working. Can you please suggest the steps to generate an interrupt?

Thank you.

zambrano.luigi
Senior III

​Hi,

please, could you share you code?

Regards,

Luigi

This is how I have tried to initialize ISR.

void ISR_Init(void)

{

INTC.MCR.B.VTES = 0;

INTC.MCR.B.HVEN = 1;

INTC.IACKR.B.VTBA = 0x08EC;

INTC.PSR[0].B.PRI = 0xF;

INTC.CPR.B.PRI = 0x0;

}

void PITimer0_ExceptionHandler(void)

{

SIU.GPDO[34].B.PDO = ~SIU.GPDO[34].B.PDO;

PIT.CH[0].TFLG.B.TIF = 1; // Clear Interrupt Flag

}

Please, check if I have written the VTBA field correct?

And let me know what I am missing.

Thank you.

Regards,

Pooja Wani

zambrano.luigi
Senior III

Hi,

in attachment you can find a project for SPC5Studio in which the interrupt of the PIT0 ch0 is managed in Hardware Mode. In SPC5Studio the PIT0 ch0 is used as system timer. The frequency and the priority of the PIT0 is configured in the function sysTimeSetup. In the linker file (application.ld) the vector table is placed at address 0x1000. The file boot.s has been modified adding the following lines:

#ifdef __ghs__

    .offset   0x8EC

#else

    .org    0x8EC

#endif

IRQ59: e_b     _IRQ59

that adds the jump to the IRQ handler _IRQ59 (interrupt related to PIT0 ch0). This handler has been defined within the file ivor.s:

    .align   4

    .globl   _IRQ59

    .type    _IRQ59, @function

_IRQ59:

    SAVE_CONTEXT

    /* Restoring pre-IRQ MSR register value.*/

    mfSRR1   %r0

    /* No preemption, keeping EE disabled.*/

    se_bclri  %r0, 16         /* EE = bit 16.         */

    mtMSR    %r0

    e_bl    vector59

    /* Informs the INTC that the interrupt has been served.*/

    mbar    0

    e_lis    %r3, HI(INTC_EOIR_BASE)

    e_or2i   %r3, LO(INTC_EOIR_BASE)

    se_stw   %r3, 0(%r3)       /* Writing any value should do. */

    RESTORE_CONTEXT

    se_rfi

The handler _IRQ9 manage the context switch and executes the jump to the function vector59 (IRQ_HANDLER(OSAL_SYSTIMER_IRQ_HANDLER) ) defined within the file osal.c, that manages the system timer. Finally, in the main function the Interrupt Hardware mode is enabled and the LED7 is toggled each 200ms. If the PIT0 is correctly managed, you should see the LED7 blinking. In order to execute the project, please import it in SPC5Studio after updating it to the last version (otherwise the modifications stored in the file patch.xml could not be correctly applied).

Best Regards,

Luigi

Hello,

It's done. Thank you.

Regards,

Pooja Wani