- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried following with CY8CKIT-043
schematic
PWM config
pins
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
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good Evening:
Wow, thank you for these attachments and code.
I will delve into this and the source code on Tuesday.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
Ken.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
So I modified the PWM configuration to One Shot with Single Trigger mode
Tera Term log was
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.