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.

SWI executed within HWI

Other Parts Discussed in Thread: SYSBIOS, TMS320C28346

Hi,


I'm just trying to migrate my project to use SYS BIOS. For that I defined a SWI which should be executed after a PWM hardware interrupt (which is not handled or configured by SYSBIOS)

If I execute the SWI_post() function in the interrupt service routine the configured SWI function is executed immediately (as I can see by toggling two pins for HWI and SWI functions)

As described the SWI function is supposed to be executed after the HWI has terminated.

What could be the problem?

I already disabled the interrupt nesting in Hwi-config but that did not change anything.

Thanks for your help!

  • Hi Andreas,

    What board (and target) are you running your app on ? Also, can you share the *.cfg or *.c code that is being used to create the PWM Hwi ?

    Best,

    Ashish

  • Hi Ashish,

    my target is a Delfino TMS320C28346 processor and I attached the app.cfg file to this post.

    You can see the Hwi code which sets the interrupt routine below. SYSBIOS is not used for this interrupt, this code is just used as it was before the project was migrated to use SYSBIOS.

            EPwm2Regs.TBPRD = period - 1;
            EPwm2Regs.TBCTR = initial - 1;
            EPwm2Regs.TBCTL.all = 0x0001; // just count down
            EPwm2Regs.ETSEL.bit.INTSEL = 1; // Interrupt Source - Enable event time-base counter equal to zero. (TBCTR = 0x0000)
            EPwm2Regs.ETSEL.all = 0x0009;
            // interrupt immediately
            EPwm2Regs.ETPS.bit.INTPRD = 1;

            if ( isr != NULL )
            {
                PieVectTable.EPWM2_INT = isr; // set interrupt service routine
                PieCtrlRegs.PIEIER3.bit.INTx2 = 1; // enable epwm2int on pie
                IER |= M_INT3; // enable cpu interrupt 3
            }

    Kind regards,

    Andreas

    app.cfg
  • Hi Ashish,


    I also got the problem that my IDLE loop (backgroundLoop ()) stops at an undefined instant of time to work. All interrupts work fine but the backgroundLoop () isn't called anymore.

    Is it possible that it is a stack problem? Would the SYSBIOS remind me in any way that it has an error and stops working now. I use the Blackhawk JTAG debugger, wouldn't run SYSBIOS in an interrupt trap which reminds me of the error?

    kind regards

    Anreas

  • Hi Andreas,

    I think I know what is causing your Swis to run in ISR context. You need to use SYS/BIOS APIs to register the ISR (i.e. use Hwi_create). SYS/BIOS Hwi module interrupts go through the dispatcher which does some initial setup (like disabling Swis and Tasks) before calling the ISR handler. If the dispatcher is skipped (which is the case in your app), then the Swis are not disabled when the ISR executes and a posted swi will run immediately.


    Best,

    Ashish

  • Hi Andreas,

    Andreas Unterberger said:

    I also got the problem that my IDLE loop (backgroundLoop ()) stops at an undefined instant of time to work. All interrupts work fine but the backgroundLoop () isn't called anymore.

    I believe this issue is also related to your app not using Hwi APIs for registering ISRs. The Hwi dispatcher saves the task context before running the ISR handler. If you directly plug-in your ISR and it is not properly saving Task context, bad things can happen when the ISR returns.

    Best,

    Ashish

  • Hi Ashish,


    thanks for the answer I will try to use the Hwi registering for my ISRs.

    In the mean time I already solved the problem by adding more memory space to the IDLE loop stack memory. To do that I had to add the Task Module to my configuration, enable the Idle-Task and set the corresponding Idle Task stack size to a higher value.

    thanks for your help!

    Andreas

  • Hi Ashish,

    in the following lines I want to ask a few questions about the general behavior of SYSBIOS especially about the user friendliness for the developer, which I experienced in this context:

    - I know the follwoing circumstance from the SYSBIOS lecture but anyway it's really confusing that the idle task stack size has to be defined through the Tasks module.

    - why doesn't notify me SYSBIOS through an interrupt trap, a log message in the raw-logs or any other way that the program execution of my background loop isn't executed anymore?
    What for is the operating system when it doesn't notify me as developer over the actions which were decided by SYSBIOS internally?

    How can I implement or switch on such a behaviour?


    kind regards

    Andreas

  • Andreas Unterberger said:

    - why doesn't notify me SYSBIOS through an interrupt trap, a log message in the raw-logs or any other way that the program execution of my background loop isn't executed anymore?

    What for is the operating system when it doesn't notify me as developer over the actions which were decided by SYSBIOS internally?

    If you open "Tools"->"ROV" and go to the "Task" view's detailed tab, you can view the current status ("Running", "Suspended", "Blocked", etc.) of each Task level thread including Idle task.

    Best,

    Ashish

  • thanks for the hint where to look for that information.

    I just had a look what the information there says if my backgroud loop in idle task says when it isn't called anymore.

    The problem I found is that the idle task is in state running, despite my own loop is not called anymore.

    Do you know any other place to look?

  • Hi Andreas,

    Rightaway no other method comes to my mind. I have a couple questions that should help me understand the problem better and maybe think of another way:

     - What code is executing when you halt the core ?

     - When you create a HWI to register an ISR, do you still see this issue ?

    Best,

    Ashish