One shot with multi trigger with PWM block

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

cross mob
KeLa_4479261
Level 4
Level 4
First like received

I am using the PSoc 4M -Series Prototyping Kit.  CY8CKIT-043

I am creating a solution which involves the generation of a waveform (GPIO output) that can be used to trigger older hardware light controllers.

I have decoded the old signal and discovered that there are 2 unique Periods with 3 different duty cycles. 

I have discovered that the CyDelayUs() is not providing me with the microsecond resolution that is required.  An associate mentioned that I should make use of the PWM components in the library.  Brought in the PWM component and setup the period and the CMP value 1.  Loaded the application and the PWM component generated a repeatable and very accurate pulse.

My goal was then to expand the design so that control when the signal generation occurred.  There is an option on the PWM component to use the "one shot with multi trigger mode".  I added in a control register block that would send a direct pulse to the PWM block.

I have been unable to get the one shot trigger working.  The PWM_Start() block has been called in main.c, the control register block is called with a value of 255 (all the bits) and the interrupt that I have attached in the PWM component never hits.

Does anyone else have any ideas for a solution.

Thanks in advance.

0 Likes
1 Solution

Hello Motoo:

Loaded code, works perfectly.

I have tweaked my copy so I can call the trigger as I build my custom waveforms.  I like the fact that this block delivers identical timings.

Regards,

Ken Lacey.

View solution in original post

7 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 tried following with CY8CKIT-043

schematic

001-schematic.JPG

PWM config

004-PWM-config1.JPG

003-PWM-config2.JPG

pins

002-pins.JPG

main.c

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

#include "project.h"

#include "stdio.h"

volatile int pwm_flag = 0 ;

CY_ISR(pwm_isr)

{

    PWM_ReadStatusRegister() ;

    pwm_flag = 1 ;

}

#define STR_LEN 64

char    str[STR_LEN+1] ;

void    print(char *str)

{

    UART_UartPutString(str) ;

}

void   printc(char c)

{

    UART_UartPutChar(c) ;

}

void cls(void)

{

    print("\033c") ; /* reset */

    CyDelay(20) ;

    print("\033[2J") ; /* clear screen */

    CyDelay(20) ;

}

void splash(void)

{

    cls() ;

    print("PSoC 4 PWM interrupt test") ;

    snprintf(str, STR_LEN, "(%s %s)\n", __DATE__, __TIME__) ;

    print(str) ;

}

void init_hardware()

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    UART_Start() ;

    splash() ;   

   

    isr_1_ClearPending() ;

    isr_1_StartEx(pwm_isr) ;

    PWM_Init() ;

}

int main(void)

{

    init_hardware() ;

   

    PWM_Enable() ;

    for(;;)

    {

        if (pwm_flag) {

            print("PWM Interrupt triggered\n\r") ;

            pwm_flag = 0 ;

            CyDelay(1000) ;

            PWM_Enable() ;

        }

    }

}

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

Tera Term log

000-TeraTerm.JPG

moto

Good Evening:

Wow, thank you for these attachments and code.

I will delve into this and the source code on Tuesday.

Thank you.

0 Likes

Good Evening Motoo:

I installed the project on PSOC 4.2 on my system.

I commented out the for(;;) loop, so I could check the one-shot trigger capability.  I forged the PIN out a port so that I could capture the toggles.

int main(void)

{

    init_hardware() ;

  

    PWM_Enable() ;

    //for(;;)

    //{

    //    if (pwm_flag) {

    //        print("PWM Interrupt triggered\n\r") ;

    //        pwm_flag = 0 ;

    //        CyDelay(1000) ;

    //        PWM_Enable() ;

    //    }

    //}

}

I hooked up my Saleae Logic Analyzer and captured a "continuous" signal.  I have enclosed the capture.

I was hoping that with the "one shot multiple tigger" that I would only see ONE period.

Is there something else that can be tried?

Please and thanks,

capture_example_Feb_18.JPG

Ken.

0 Likes
lock attach
Attachments are accessible only for community members.
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi KeLa_4479261

I have attached a modified code that uses control registers as trigger events to show the One-shot capability. The trigger input is also enabled in the PWM component. This triggers the PWM on every button press.

Please try this out at your end.

Thanks,
Hari

Hello AH_96:

This is the same message I sent to Motoo.  Thank you for your help.

Loaded code, works perfectly.

I have tweaked my copy so I can call the trigger as I build my custom waveforms.  I like the fact that this block delivers identical timings.

Regards,

Ken Lacey.

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

So I modified the PWM configuration to One Shot with Single Trigger mode

010-oneshot-single.JPG

Tera Term log was

011-TeraTerm.JPG

So only 1 pulse will be generated.

Or you could change CyDelay(xxx) to much longer period in the previous project then you could see single pulse repeated in a interval.

moto

0 Likes

Hello Motoo:

Loaded code, works perfectly.

I have tweaked my copy so I can call the trigger as I build my custom waveforms.  I like the fact that this block delivers identical timings.

Regards,

Ken Lacey.