Consult GPIO to simulate timer interrupts

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

cross mob
Demi1
Level 1
Level 1
25 sign-ins First like given 5 replies posted

Hi,sir,

for PSOC4100S series, is it possible to use GPIO to simulate timer interrupts in addition to the 5-way PWM?

 If it is possible, can you provide the example program?

Thanks for the answer!

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

Hi,

Interrupt interval can be 1ms or 2ms

Then you should be able to use SysTick Timer.

Please refer to the links in my previous response.

moto

View solution in original post

0 Likes
8 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,

From your description, I could not figure out what you want to do with the 5-way PWM.

So I just wrote a sample which takes a GPIO input (SW as active-low) for interrupt source

and just toggle an output LED. (You can change sw_isr() to do what you want with the PWM)

I used a TSoC board which has CY8C4146LQI-S433.

 

schematic

001-schematic.JPG

SW config

003-SW_config.JPG

LED config

004-LED_config.JPG

Pins

002-pins.JPG

main.c

#include "project.h"

#define LED_ON (1u)
#define LED_OFF (0u)

CY_ISR(sw_isr)
{
    SW_ClearInterrupt() ;
    
    if (LED_Read() == LED_ON) {
        LED_Write(LED_OFF) ;
    } else {
        LED_Write(LED_ON) ;
    }
}

void init_hardware(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */    
    
    LED_Write(LED_OFF) ;
    
    isr_1_ClearPending() ;
    isr_1_StartEx(sw_isr) ;
}

int main(void)
{
    init_hardware() ; 
    
    for(;;)
    {
        /* Place your application code here. */
    }
}

 

moto

0 Likes
Gautami_12
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @Demi1 ,

Can you please let us know in which software you are simulating this project?
Can you please clarify about 5-way PWM and simulating timer interrupts? Are you referring to the 5 TCPWM blocks present in the 4100s device?

If this is the case, you may re-route the PWM output(s) to a different pin(s) by using Smart-IO. You can refer to smart i/o_pwm_ramping_led to know about Smart I/O.

You can use the following code example as a reference (for ModusToolbox): mtb-example-psoc4-tcpwm-interrupt  and mtb-example-psoc4-gpio

Please also refer to:-

PWM Timer and De multiplexer on PSOC4100S 
GPIO Interrupts 

Warm Regards
Gautami J

 

0 Likes

Hi, Gautami J

thank you for your help, this is how the customer simulates this project in PSOC creator software.
The customer is already using 5 TCPWM modules as PWM outputs in the 4100S device; he also wants to use timer interrupts, how do I implement it?
Thank you for your answer!

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

Hi,

What is the required interval of timer interrupt?

moto

0 Likes

Hi,Sir,

Interrupt interval can be 1ms or 2ms

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

Hi,

Interrupt interval can be 1ms or 2ms

Then you should be able to use SysTick Timer.

Please refer to the links in my previous response.

moto

0 Likes

Thank you for your patience in answering my questions.