Skip to main content
orhanyilmaz
Associate III
November 4, 2014
Solved

Low Level Interrupt Control Problem

  • November 4, 2014
  • 2 replies
  • 991 views
Posted on November 04, 2014 at 12:58

Hello,

I'm trying register base interrupt control. But not working.(problem *.s files)

I do not

want to use to OSAL library.

Not starting interrupt. Example Code:

//Orhan YILMAZ
//Timer Example
typedef
enum
{
FALSE,
TRUE
}
BOOL
;
void
StartupInit(
void
);
void
Port_conig(
void
);
void
WDT_disable(
void
);
void
PIT0_Init(unsigned 
int
TimeOut);
void
PIT0_Start(
void
);
//void PIT_0_Handler(void);
void
Interrup_Enable(
void
);
#include ''components.h''
#include ''xpc560b.h''
/*
* Application entry point.
*/
unsigned 
long
i = 0;
int
main(
void
) {
componentsInit();
//CLK Init.
StartupInit();
//WDT Disable
WDT_disable();
//Port
Port_conig();
//Timer
PIT0_Init(0xFFFFF);
//IRQ Config
Interrup_Enable();
PIT0_Start();
while
(TRUE) {
if
(i == 0xFFFFFF)
{
//SIU.GPDO[90].B.PDO ^= 1;
i = 0;
}
i++;
}
}
//PORT CONFIGURATION
void
Port_conig(
void
)
{
//Working Led
SIU.PCR[90].B.OBE = 1;
SIU.GPDO[90].B.PDO = 0;
//Output Low
}
//PIT0 Initial Function
void
PIT0_Init(unsigned 
int
TimeOut)
{

PIT.PITMCR.R = 0x000000001;
//Enable PIT and Configure to stop in debug mode
PIT.CH[0].LDVAL.R = TimeOut;
//Timeout enter
//Tclk = SystemCLK
INTC_PSR(PIT0_VECTOR)=5;
//PIT_0_Handler, 59, 5;
IRQ_HANDLER(PIT_0_Handler);
}
//PIT0 Start Function
void
PIT0_Start(
void
)
{
//TIE = 1 Timer Interrup Enable
//TEN = 1 Timer Enable
PIT.CH[0].TCTRL.R = 3;
}
void
WDT_disable(
void
)
{
//Watchdog Timer Disable
SWT.SR.R = 0x0000c520; 
/* Write keys to clear soft lock bit */
SWT.SR.R = 0x0000d928;
SWT.CR.R = 0x8000010A; 
/* Clear watchdog enable (WEN) */
}
/*************************
*CLK CONFIGURATION
*************************/
void
StartupInit(
void
)
{

*

* * * * * * *

//Check Configurations
while
(ME.GS.B.MTRANS);
//Global Status Register wait for mode transition to complete
while
(ME.GS.B.CURRENTMODE != 4);
//Global Status Register verify RUN0 Current mode
}
//*********IRQ***********//
void
Interrup_Enable(
void
)
{
INTC.CPR.B.PRI = 0; 
// Lower INTC's current priority
asm(
''wrteei 1''
); 
//Enable external interrupt ================>>> PROBLEM THIS LINE
}
void
PIT_0_Handler(
void
)
{
PIT.CH[0].TFLG.B.TIF = 1;
SIU.GPDO[90].B.PDO ^= 1;
}

Note: ivor.s and vector.s copy my project folder. Thanks. Best Regards, Orhan YILMAZ
    This topic has been closed for replies.
    Best answer by Erwan YVIN
    Posted on November 14, 2014 at 13:52 Hello Orhan , Do you want enable PIT 0 Channel handler ? if yes , you have to update your application and use the vector59 (Channel PIT 0) your vector59 handler is already defined in hal_lld.c. if you want to customize it stub ''hal_lld.c '' by using PATCH MODE FEATURE in SPC5Studio 3.3 Example Code hal_lld.c :

    /**
    * @brief PIT channel 0 interrupt handler.
    *
    * @isr
    */
    #if 0
    OSAL_IRQ_HANDLER(vector59) {
    OSAL_IRQ_PROLOGUE();
    osalSysLockFromISR();
    osalOsTimerHandlerI();
    osalSysUnlockFromISR();
    /* Resets the PIT channel 0 IRQ flag.*/
    PIT.CH[0].TFLG.R = 1;
    OSAL_IRQ_EPILOGUE();
    }
    #endif

    Example Code main.c (cf below) V2.0: you can see the LED is blinking when the interruption PIT0 happenned

    //Orhan YILMAZ v2.0 (Updated by Erwan)
    //Timer Example
    typedef
    enum
    {
    FALSE,
    TRUE
    }
    BOOL
    ;
    #define PIT0_VECTOR 59
    void
    StartupInit(
    void
    );
    void
    Port_conig(
    void
    );
    void
    WDT_disable(
    void
    );
    void
    PIT0_Init(unsigned 
    int
    TimeOut);
    void
    PIT0_Start(
    void
    );
    static
    void
    PIT_0_Handler(
    void
    );
    /**
    * @brief IRQ handler function declaration.
    * @details This macro hides the details of an ISR function declaration.
    *
    * @param[in] id a vector name as defined in @p vectors.s
    */
    #define IRQ_HANDLER(id) void id(void)
    void
    Interrup_Enable(
    void
    );
    #include ''components.h''
    #include ''xpc560b.h''
    /*
    * Application entry point.
    */
    unsigned 
    long
    i = 0;
    int
    main(
    void
    ) {
    componentsInit();
    //CLK Init.
    StartupInit();
    //WDT Disable
    WDT_disable();
    //Port
    Port_conig();
    //Timer
    PIT0_Init(0xFFFFF);
    //IRQ Config
    Interrup_Enable();
    PIT0_Start();
    while
    (TRUE) {
    if
    (i == 0xFFFFFF)
    {
    //SIU.GPDO[90].B.PDO ^= 1;
    i = 0;
    }
    i++;
    }
    }
    //PORT CONFIGURATION
    void
    Port_conig(
    void
    )
    {
    //Working Led
    SIU.PCR[90].B.OBE = 1;
    SIU.GPDO[90].B.PDO = 0;
    //Output Low
    }
    //PIT0 Initial Function
    void
    PIT0_Init(unsigned 
    int
    TimeOut)
    {
    PIT.PITMCR.R = 0x000000001;
    //Enable PIT and Configure to stop in debug mode
    PIT.CH[0].LDVAL.R = TimeOut;
    //Timeout enter
    //Tclk = SystemCLK
    INTC_PSR(PIT0_VECTOR)=5;
    //PIT_0_Handler, 59, 5;
    }
    /**
    * @brief PIT channel 0 interrupt handler.
    *
    * @isr
    */
    IRQ_HANDLER(vector59) {
    PIT_0_Handler();
    }
    //PIT0 Start Function
    void
    PIT0_Start(
    void
    )
    {
    //TIE = 1 Timer Interrup Enable
    //TEN = 1 Timer Enable
    PIT.CH[0].TCTRL.R = 3;
    }
    void
    WDT_disable(
    void
    )
    {
    //Watchdog Timer Disable
    SWT.SR.R = 0x0000c520; 
    /* Write keys to clear soft lock bit */
    SWT.SR.R = 0x0000d928;
    SWT.CR.R = 0x8000010A; 
    /* Clear watchdog enable (WEN) */
    }
    /*************************
    *CLK CONFIGURATION
    *************************/
    void
    StartupInit(
    void
    )
    {
    //Check Configurations
    while
    (ME.GS.B.MTRANS);
    //Global Status Register wait for mode transition to complete
    while
    (ME.GS.B.CURRENTMODE != 4);
    //Global Status Register verify RUN0 Current mode
    }
    //*********IRQ***********//
    void
    Interrup_Enable(
    void
    )
    {
    INTC.CPR.B.PRI = 0; 
    // Lower INTC's current priority
    asm(
    ''wrteei 1''
    ); 
    //Enable external interrupt ================>>> PROBLEM THIS LINE
    }
    static
    void
    PIT_0_Handler(
    void
    )
    {
    PIT.CH[0].TFLG.B.TIF = 1;
    SIU.GPDO[90].B.PDO ^= 1;
    palTogglePad(PORT_E, PE_LED1);
    }

    Best Regards Erwan

    2 replies

    Erwan YVIN
    Erwan YVINBest answer
    ST Employee
    November 14, 2014
    Posted on November 14, 2014 at 13:52 Hello Orhan , Do you want enable PIT 0 Channel handler ? if yes , you have to update your application and use the vector59 (Channel PIT 0) your vector59 handler is already defined in hal_lld.c. if you want to customize it stub ''hal_lld.c '' by using PATCH MODE FEATURE in SPC5Studio 3.3 Example Code hal_lld.c :

    /**
    * @brief PIT channel 0 interrupt handler.
    *
    * @isr
    */
    #if 0
    OSAL_IRQ_HANDLER(vector59) {
    OSAL_IRQ_PROLOGUE();
    osalSysLockFromISR();
    osalOsTimerHandlerI();
    osalSysUnlockFromISR();
    /* Resets the PIT channel 0 IRQ flag.*/
    PIT.CH[0].TFLG.R = 1;
    OSAL_IRQ_EPILOGUE();
    }
    #endif

    Example Code main.c (cf below) V2.0: you can see the LED is blinking when the interruption PIT0 happenned

    //Orhan YILMAZ v2.0 (Updated by Erwan)
    //Timer Example
    typedef
    enum
    {
    FALSE,
    TRUE
    }
    BOOL
    ;
    #define PIT0_VECTOR 59
    void
    StartupInit(
    void
    );
    void
    Port_conig(
    void
    );
    void
    WDT_disable(
    void
    );
    void
    PIT0_Init(unsigned 
    int
    TimeOut);
    void
    PIT0_Start(
    void
    );
    static
    void
    PIT_0_Handler(
    void
    );
    /**
    * @brief IRQ handler function declaration.
    * @details This macro hides the details of an ISR function declaration.
    *
    * @param[in] id a vector name as defined in @p vectors.s
    */
    #define IRQ_HANDLER(id) void id(void)
    void
    Interrup_Enable(
    void
    );
    #include ''components.h''
    #include ''xpc560b.h''
    /*
    * Application entry point.
    */
    unsigned 
    long
    i = 0;
    int
    main(
    void
    ) {
    componentsInit();
    //CLK Init.
    StartupInit();
    //WDT Disable
    WDT_disable();
    //Port
    Port_conig();
    //Timer
    PIT0_Init(0xFFFFF);
    //IRQ Config
    Interrup_Enable();
    PIT0_Start();
    while
    (TRUE) {
    if
    (i == 0xFFFFFF)
    {
    //SIU.GPDO[90].B.PDO ^= 1;
    i = 0;
    }
    i++;
    }
    }
    //PORT CONFIGURATION
    void
    Port_conig(
    void
    )
    {
    //Working Led
    SIU.PCR[90].B.OBE = 1;
    SIU.GPDO[90].B.PDO = 0;
    //Output Low
    }
    //PIT0 Initial Function
    void
    PIT0_Init(unsigned 
    int
    TimeOut)
    {
    PIT.PITMCR.R = 0x000000001;
    //Enable PIT and Configure to stop in debug mode
    PIT.CH[0].LDVAL.R = TimeOut;
    //Timeout enter
    //Tclk = SystemCLK
    INTC_PSR(PIT0_VECTOR)=5;
    //PIT_0_Handler, 59, 5;
    }
    /**
    * @brief PIT channel 0 interrupt handler.
    *
    * @isr
    */
    IRQ_HANDLER(vector59) {
    PIT_0_Handler();
    }
    //PIT0 Start Function
    void
    PIT0_Start(
    void
    )
    {
    //TIE = 1 Timer Interrup Enable
    //TEN = 1 Timer Enable
    PIT.CH[0].TCTRL.R = 3;
    }
    void
    WDT_disable(
    void
    )
    {
    //Watchdog Timer Disable
    SWT.SR.R = 0x0000c520; 
    /* Write keys to clear soft lock bit */
    SWT.SR.R = 0x0000d928;
    SWT.CR.R = 0x8000010A; 
    /* Clear watchdog enable (WEN) */
    }
    /*************************
    *CLK CONFIGURATION
    *************************/
    void
    StartupInit(
    void
    )
    {
    //Check Configurations
    while
    (ME.GS.B.MTRANS);
    //Global Status Register wait for mode transition to complete
    while
    (ME.GS.B.CURRENTMODE != 4);
    //Global Status Register verify RUN0 Current mode
    }
    //*********IRQ***********//
    void
    Interrup_Enable(
    void
    )
    {
    INTC.CPR.B.PRI = 0; 
    // Lower INTC's current priority
    asm(
    ''wrteei 1''
    ); 
    //Enable external interrupt ================>>> PROBLEM THIS LINE
    }
    static
    void
    PIT_0_Handler(
    void
    )
    {
    PIT.CH[0].TFLG.B.TIF = 1;
    SIU.GPDO[90].B.PDO ^= 1;
    palTogglePad(PORT_E, PE_LED1);
    }

    Best Regards Erwan
    orhanyilmaz
    Associate III
    November 28, 2014
    Posted on November 28, 2014 at 13:23

    Thanks for reply. But,

    I had

    to solve

    in a different way

    . (3 week ago)

    .

    Best Regards

    Orhan YILMAZ

    Hank Im
    Associate II
    August 10, 2017
    Posted on August 10, 2017 at 09:00

    Hello!

    I have the same problem too.

    If you don't mind, please let me know the solution in detail.

    Thank you.