6 Replies Latest reply on Apr 5, 2018 10:23 PM by pria

    SVCall, PendSV and Systik in PSoC4

    user_474444345

      Hello,

       

      I am porting OS into PSoC4. I have to relate variables of SVCall, PendSv and Systik declared in OS source code into handlers of PSoC4.

      But I cannot find how those three handler is defined and is declared in PSoC4.

       

      What documentation that is written down in?

       

      Best regards,

        • 1. Re: SVCall, PendSV and Systik in PSoC4
          user_1377889

          Have a look into the "System Reference Guide" (from Creator Help menu). Everything is explained there. There are no handlers for your interrupts yet, you'll have to provide them yourself.

           

          Bob

          • 2. Re: SVCall, PendSV and Systik in PSoC4
            user_474444345

            Hello,

             

            I know how to use handlers from peripherals. But I would like to know the method to use interrupts defined by Cortex-M0.

            Basically, CM0 MCU of STM or NXP define the handler start up file. Also FM0+ is the same as STM or NXP.

             

            It is easy to modify the handler name. Because it is just rename by #define.

            Whereas Creator have to define CY_ISR() and CY_ISR_PROTO() or API for peripheral. But there is no information for SVCall or others in PSoC Creator User Guide because I searched key word with SVC or Pend but did not hit in PDF.

             

            Please let me know example code.

             

            Best regards,

            • 3. Re: SVCall, PendSV and Systik in PSoC4
              e.pratt_1639216

              There is no default software for "SVC" or "Pend" in the PSoC generated code;

              To associate a handler with the callback, you would need to call the ISR_startex(callback_handler); function with the associated peripheral that you want to be handled by the function.

              Or, if you have the handler function prototype/name written to match the default naming of the peripheral, then you can use just ISR_Start();

              Look up the documentation on ISRs and interrupt handling to see example code and the two methods I mentioned above.

              • 4. Re: SVCall, PendSV and Systik in PSoC4
                user_474444345

                Hello,

                 

                If I put a component has interrupt function such as "Interrupt" or "SCB" in Schematic space, I can indicate the component name into the API of ISR(Component Name)_StartEx(); or ISR(Component Name)_SetVector();. But SVC, PendSV and SysTick are not peripheral such as components prepared by Cypress. Those are common exceptions in Cortex-M MCU.

                 

                Generally, Interrupt handler name is defined in a start up file .s, but the start up file generated by Creator does not have the definitions for handler. Whereas, start up file of PSoC6 has the definitions.

                 

                +++++++++++++++++++++++++++++++++++++++++

                SVC_Handler

                        B SVC_Handler

                 

                        PUBWEAK PendSV_Handler

                        SECTION .text:CODE:REORDER:NOROOT(1)

                PendSV_Handler

                        B PendSV_Handler

                 

                        PUBWEAK SysTick_Handler

                        SECTION .text:CODE:REORDER:NOROOT(1)

                SysTick_Handler

                        B SysTick_Handler

                ++++++++++++++++++++++++++++++++++++++++++

                 

                If the handlers is defiled like PSoC6, I can use the handler in my source code such as below.

                 

                void SVC_Handler()

                {

                     /* Write handler behavior*/

                }

                 

                However, PSoC4 does not have the description in start up file.

                Therefore, I have to use the API for component peripherals but the component for SVC, PendSV and Systick are not prepared in Component Catalog. So I am confusing how to use and indicate those in Creator.

                 

                Below is about PSoC5 and FreeRTOS.

                SVC, PendSV and Systik handler is defined by function pointer, and the definition is set to ram address like below.

                 

                +++++++++++++++++++++++++++++++++++++++++++++++++

                extern void xPortPendSVHandler( void );

                extern void xPortSysTickHandler( void );

                extern void vPortSVCHandler( void );

                extern cyisraddress CyRamVectors[];

                 

                    CyRamVectors[ 11 ] = ( cyisraddress ) vPortSVCHandler;

                    CyRamVectors[ 14 ] = ( cyisraddress ) xPortPendSVHandler;

                    CyRamVectors[ 15 ] = ( cyisraddress ) xPortSysTickHandler;

                ++++++++++++++++++++++++++++++++++++++++++++++++++

                 

                I understand if we offset vector table address from flash to ram, we can call the vPortSVCHandler, xPortPendSVHandler and xPortSysTickHandler when those exception happen. But it spend ram space and it is not easy to read and the cause of confusing in future. So at first, I would like to know the interrupt algorithm for PSoC4 to make ideal environment for my system.

                 

                Please kindly let me know an example or documentation for available of these handlers.

                 

                Best regards,

                • 5. Re: SVCall, PendSV and Systik in PSoC4
                  e.pratt_1639216

                  The FreeRTOS example has references to the SVC in it: http://www.cypress.com/blog/technical/freertos-psoc-component

                  Here is a thread where someone wanted to setup the same thing: Are there software interrupts on PSoC4?

                  user_1377889 answers are useful from what I am looking at

                  • 6. Re: SVCall, PendSV and Systik in PSoC4
                    pria

                    You can declare your own handler for these interrupts, and install the ISR in its appropriate entry in the interrupt vector table. An example code for PSoC4000 is as below:

                     

                    CY_ISR(FastTimerIsr);

                    CY_ISR(PendedCallbackIsr);

                     

                    /* Pointer to the function to be called back by the PendSV ISR */

                    typedef void (* PENDEDCALLBACK_PTR)(void);

                     

                    /* Pointer to pended callback function */

                    volatile PENDEDCALLBACK_PTR pendedCallbackPtr; 

                     

                    void InitializeInterrupts(void)

                    {

                         /* Setup interrupt vectors */

                    CyIntSetSysVector(CY_INT_SYSTICK_IRQN, &FastTimerIsr);

                    CyIntSetSysVector(CY_INT_PEND_SV_IRQN, &PendedCallbackIsr);

                     

                         /* Set the interrupt priority, SHPR3 has SYSTICK and PENDSV priority */

                    CY_SET_REG32(CYREG_CM0_SHPR3,

                    (INTERRUPT_PRIORITY_1 << CM0_SHPR3_PRI_14_SHIFT) | (INTERRUPT_PRIORITY_1 << CM0_SHPR3_PRI_15_SHIFT));

                    }

                     

                    void RegisterPendedCallback(PENDEDCALLBACK_PTR callbackPtr)

                    {   

                        /* Register the function callback */

                    pendedCallbackPtr = callbackPtr;

                    }

                     

                    void InvokePendedCallback(void)

                    {   

                        /* Set PendSV interrupt state to pending */

                        CY_SET_REG32(CYREG_CM0_ICSR, SCB_ICSR_PENDSVSET_Msk);

                    }

                     

                    CY_ISR(PendedCallbackIsr)

                    {

                        /* Clear PendSV interrupt pending status */

                    CY_SET_REG32(CYREG_CM0_ICSR, SCB_ICSR_PENDSVCLR_Msk);

                     

                        /* Call the pended function registered */

                    pendedCallbackPtr();

                    }

                    2 of 2 people found this helpful