Skip to main content
Binbin Zhang
Associate II
May 3, 2017
Question

SPC560D40x - Interrupt Duration

  • May 3, 2017
  • 3 replies
  • 2391 views
Posted on May 03, 2017 at 05:45

Hi ST expert,

I am trying to use SPC5 as a multi-channel PWM controller. Normally for this kind of application, the duty cycle calculation will be done in an interrupt. For 100kHz PWM, the allowed interrupt duration is <10uS, for example 8uS max. The rest of time (10uS-8uS=2uS) should be reserved for other processes, such as communication etc.

As there is a lot calculation for multi-channel PWM, it is necessary to maximize the usage of the interrupt duration. However, I found it will take >1.2uS to enter an interrupt and take another 1uS to go back to the main routine for 48MHz clock. That means >40% of the interrupt duration will be wasted. Attached is my program used to test the interrupt duration and the captured waveform - PIT Channel 1 as the trigger source; PC9 is the output.

My question here is why SPC5 needs so many clocks to enter and left the interrupt and is there any way to reduce such unnecessary timing?

Thank you!

#intc
    This topic has been closed for replies.

    3 replies

    Erwan YVIN
    ST Employee
    May 4, 2017
    Posted on May 04, 2017 at 09:43

    Hello BinBin ,

    I am checking with Application team.

    did you use RLA / HAL / your own interruption handler?

        Best regards

                        Erwan

    Binbin Zhang
    Associate II
    May 4, 2017
    Posted on May 04, 2017 at 10:22

    Hello Erwan,

    Thank you for your help.

    I tried both RLA and HAL interruption handler and the result is the same. I found this problem when I worked on a program at eMIOs OPWMB mode. Later I verified it with PIT interruption. Attached herewith is my simple program and its result for your reference.

    Thank you again and look forward to your reply.

    Best Regards,

    ZHANG Binbin(张斌斌)

    Goldpower Tech Pte Ltd

    Tel: +65-6294 7577

    Fax: +65-6294 7477

    ________________

    Attachments :

    PIT1_ISR.txt.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hygg&d=%2Fa%2F0X0000000bAv%2Fe74NsdKPS1UJz4_mwIr595q8TKA.C2BATlNhpnXWlBI&asPdf=false

    ISR_Timing.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hygb&d=%2Fa%2F0X0000000bAw%2F0h09Rp47XH5fYdbdkMiLiiXZJV0Y2n6DSazqvtGmdRU&asPdf=false
    Binbin Zhang
    Associate II
    May 29, 2017
    Posted on May 29, 2017 at 02:26

    Please follow-up this subject. 

    Thanks!

    Erwan YVIN
    ST Employee
    June 14, 2017
    Posted on June 14, 2017 at 10:31

    Hello Binbin ,

    The Interrupt handler is managed in ivor.s

    (Cf Code below)

    _IVOR4:
     SAVE_CONTEXT
     /* Software vector address from the INTC register.*/
     e_lis %r3, HI(INTC_IACKR_BASE) /*IACKR register address. */
     e_or2i %r3, LO(INTC_IACKR_BASE)
     se_lwz %r3, 0(%r3) /* IACKR register value. */
     se_lwz %r3, 0(%r3)
     se_mtCTR %r3 /* Software handler address. */
     /* Restoring pre-IRQ MSR register value.*/
     mfSRR1 %r0
     /* No preemption, keeping EE disabled.*/
     se_bclri %r0, 16 /* EE = bit */
     mtMSR %r0
    #if (OSAL_ENABLE_IRQ_PREEMPTION == TRUE)
     /* Allows preemption while executing the software handler.*/
     wrteei 1
    #endif /* OSAL_ENABLE_IRQ_PREEMPTION */
     /* Executes the software handler.*/
     se_bctrl
    #if (OSAL_ENABLE_IRQ_PREEMPTION == TRUE)
     /* Prevents preemption again.*/
     wrteei 0
    #endif /* OSAL_ENABLE_IRQ_PREEMPTION */
     /* 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�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

    Could you increase PWM Interrupt priority and enable OSAL_ENABLE_IRQ_PREEMPTION (cf OSAL Component)?

    Best regards

    Erwan

    raghu tumati
    Associate III
    September 20, 2017
    Posted on September 20, 2017 at 19:05

    Hi Binbin

    I think I am having a similar problem using the PIT. I am trying to generate a timer interrupt every 1.7uS to toggle a GPIO and it does not seem to be working. In fact any timer setting <4us is quite unstable and I cannot get the timer to interrupt < 2.5uS. The lowest setting for a stable timer I can get is ~5us. 

    I believe it is because of the number of cycles its taking to get to the ISR and back. 

    Were you able to solve the problem by giving it a higher interrupt priority or any other way?

    Thanks