Skip to main content
Pooja WANI
Associate III
July 10, 2019
Solved

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?

  • July 10, 2019
  • 3 replies
  • 1850 views

..

    This topic has been closed for replies.
    Best answer by zambrano.luigi

    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

    3 replies

    zambrano.luigi
    zambrano.luigiBest answer
    ST Employee
    July 12, 2019

    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

    Pooja WANI
    Associate III
    July 15, 2019

    Thank You.

    zambrano.luigi
    ST Employee
    July 16, 2019

    ​Hi,

    please, could you share you code?

    Regards,

    Luigi

    Pooja WANI
    Associate III
    July 17, 2019

    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
    ST Employee
    July 17, 2019

    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

    Pooja WANI
    Associate III
    July 19, 2019

    Hello,

    It's done. Thank you.

    Regards,

    Pooja Wani