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

PSoC™ 4 Forum Discussions

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

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
First comment on KBA 1000 replies posted 750 replies posted
Level 9

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
MotooTanaka
Level 9
First comment on KBA 1000 replies posted 750 replies posted
Level 9

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 100 sign-ins 25 solutions authored 50 replies posted
Moderator

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
Demi1
Level 1
25 sign-ins First like given 5 replies posted
Level 1

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
First comment on KBA 1000 replies posted 750 replies posted
Level 9

Hi,

What is the required interval of timer interrupt?

moto

0 Likes
Demi1
Level 1
25 sign-ins First like given 5 replies posted
Level 1

Hi,Sir,

Interrupt interval can be 1ms or 2ms

0 Likes
MotooTanaka
Level 9
First comment on KBA 1000 replies posted 750 replies posted
Level 9

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
Demi1
Level 1
25 sign-ins First like given 5 replies posted
Level 1

Thank you for your patience in answering my questions.