TCPWM_Init() fuctions blocks the interrupt?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
KoGi_2879686
Level 1
Level 1
First like received First like given Welcome!

Hello,

I have this strange behaviour from a TCPWM block: Which is called "TCPWM_Trottle_response"
     It is configured as:
     timer/counter

     Interrupt on terminal count
   

               Code that works perfectly well:

               CyGlobalIntEnable;

               TCPWM_Trottle_response_Start();

               Trottle_repsonse_interrupt_StartEx( Trottle_repsonse_interrupt_handler);

               Interrupt routine:

CY_ISR(Trottle_repsonse_interrupt_handler)

{

    #ifdef __DEBUG

        UART_1_UartPutString("ISR Trottle\r\n");

    #endif

    PinTest_Write(~PinTest_Read());

    TCPWM_Trottle_response_ClearInterrupt(TCPWM_Trottle_response_INTR_MASK_TC);

}

               Code that does not work:

                CyGlobalIntEnable;

                TCPWM_Trottle_response_Init();

                TCPWM_Trottle_response_Start();

                Trottle_repsonse_interrupt_StartEx( Trottle_repsonse_interrupt_handler);

Does the TCPWM_init() function block the interrupt ?

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Wow, what a cute boy!

I'm a little bit lost where you are now.

So is your first issue solved or still remaining?

But, meantime if you want to catch interrupt(s) of both fall and rise edge of a pin,

you could do something like

000_ON_OFF_INT_sketch.JPG

Then you can take care of each events in different ISRs,

moto

View solution in original post

4 Replies
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I tested with following main.c using CY8CKIT-044.

With both good and bad cases including when __DEBUG is defined and not defined

for all 4 cases, the interrupt in my project did not get blocked.

So I would think that TCPWM_Init() does not block the interrupt (at least not always)

At first I thought that you were defining __DEBUG and UART_1_UartPutString() was

called before UART_1_Start(), which I intentionally placed after your initialization,

but my project worked even with this condition.

So there must be some other reason in your project to make TCPWM_Init() block,

probably some setting(s) of TCPWM.

It would be nice if you can upload a sample project which can reproduce your problem.

(schematic)

tcpwm_init_schematic.JPG

main.c

=======================

/**

* TCPWM_Init() function test

https://community.cypress.com/thread/45550

*/

#include "project.h"

#include "stdio.h"

// #define __DEBUG

char str[128] ; /* print buffer */

void print(char *str)

{

    UART_1_UartPutString(str) ;

}

CY_ISR(Trottle_response_interrupt_handler)

{

#ifdef __DEBUG

    UART_1_UartPutString("ISR Trottle\r\n") ;

#endif

    PinTest_Write(~PinTest_Read()) ;

    TCPWM_Trottle_response_ClearInterrupt(TCPWM_Trottle_response_INTR_MASK_TC) ;

}

int main(void)

{

#if 0  /* case 1 */

    CyGlobalIntEnable; /* Enable global interrupts. */

    TCPWM_Trottle_response_Start() ;

    Trottle_response_interrupt_StartEx( Trottle_response_interrupt_handler) ;

#else

    CyGlobalIntEnable; /* Enable global interrupts. */

    TCPWM_Trottle_response_Init() ;

    TCPWM_Trottle_response_Start() ;

    Trottle_response_interrupt_StartEx( Trottle_response_interrupt_handler) ; 

#endif

    UART_1_Start() ;

    sprintf(str, "TCPWM_Init() test (%s %s)\n", __DATE__, __TIME__) ;

    print(str) ;

    for(;;)

    {

        /* Place your application code here. */

    }

}

=======================

moto

0 Likes
lock attach
Attachments are accessible only for community members.

Hi,

Thanks for your input, I have included the project archive.

To give you some context, I modded my son's kidcar with BLDCs and I am now writing new firmware 😉

IMG_1626.jpg

I currently also have a new issue 😉
The pedal, power switch and gear stick  are on port 5, 5.0, 5.1, 5.2  resp.

pins.PNG

I have an interrupt routine:

CY_ISR( Trottle_switch_interrupt_handler )

{

    uint8 interruptSources = Pin_SW_Throtlle_foot_ClearInterrupt();

    char msg[20] = "";

    sprintf(msg, "ISR Trottle Switch %d\r\n", interruptSources);

    if( (interruptSources & 0b00000001) == 1){

        Trottle_switch_interrupt_ClearPending();

        #ifdef __DEBUG

            UART_1_UartPutString(msg);

        #endif

        PinLed_Write(Pin_SW_Throtlle_foot_Read());

    }

}

The interrupt gets triggered on both edge of pin 5.0 but also on pin 5.2 which is offcourse not feasible.

Any thoughts ?
Thanks for your consideration.

KoGi_2879686
Level 1
Level 1
First like received First like given Welcome!

I currently also have a new issue 😉
The pedal, power switch and gear stick  are on port 5, 5.0, 5.1, 5.2  resp.

pins.PNG

I have an interrupt routine:

CY_ISR( Trottle_switch_interrupt_handler )

{

    uint8 interruptSources = Pin_SW_Throtlle_foot_ClearInterrupt();

    char msg[20] = "";

    sprintf(msg, "ISR Trottle Switch %d\r\n", interruptSources);

    if( (interruptSources & 0b00000001) == 1){

        Trottle_switch_interrupt_ClearPending();

        #ifdef __DEBUG

            UART_1_UartPutString(msg);

        #endif

        PinLed_Write(Pin_SW_Throtlle_foot_Read());

    }

}

The interrupt gets triggered on both edge of pin 5.0 but also on pin 5.2 which is offcourse not feasible.

This problem is solved by:

group-pins.PNG

Now I can discriminate between the interrupt sources.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Wow, what a cute boy!

I'm a little bit lost where you are now.

So is your first issue solved or still remaining?

But, meantime if you want to catch interrupt(s) of both fall and rise edge of a pin,

you could do something like

000_ON_OFF_INT_sketch.JPG

Then you can take care of each events in different ISRs,

moto