need example one-shot project for CY8CPROTO-063-BLE

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

cross mob
lock attach
Attachments are accessible only for community members.
MaLe_297531
Level 2
Level 2
10 sign-ins 5 replies posted First like received

I am using PSoC Creator to configure a counter in one-shot mode. I have a CY8CPROTO-063-BLE board. The target device is CYBLE-416045-02. How do I configure the following? On the falling edge of the button on P0[4], a counter outputs 10 cycles of a 1kHz input clock on pin P6[3]. After these 10 cycles, pin P6[3] stays low, the counter resets. The system waits for the next falling edge of the button input, starting the process over again. I would prefer a solution that configures the counter mainly through the configuration GUI.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MaLe_297531
Level 2
Level 2
10 sign-ins 5 replies posted First like received

Andri,

I figured out my solution. A screenshot of the schematic is attached. The code is below.

The pulses come out on the Red LED pin. When SW2 is pressed, N pulses are generated, then wait for the next button press.

The code is very simple.

#include "project.h"

int main(void)
{
(void) Cy_TCPWM_PWM_Init(PWM_HW, PWM_CNT_NUM, &PWM_config);
Cy_TCPWM_Enable_Multiple(PWM_HW, PWM_CNT_MASK);
Cy_TCPWM_TriggerStart(PWM_HW, PWM_CNT_MASK);

(void)Cy_TCPWM_Counter_Init(Counter_HW, Counter_CNT_NUM, &Counter_config);
Cy_TCPWM_Enable_Multiple(Counter_HW, Counter_CNT_MASK);
Cy_TCPWM_TriggerStart(Counter_HW, Counter_CNT_MASK);

for(;;)
{

}
}

View solution in original post

6 Replies
lock attach
Attachments are accessible only for community members.
ADSW
Moderator
Moderator
Moderator
250 sign-ins 50 solutions authored 25 likes received

Hello @MaLe_297531 , 

From your statement " After these 10 cycles, pin P6[3] stays low, the counter resets.  " ,
Do you mean the pin P6_3 will set high after the button is pressed then goes to LOW after several ticks (10ms ) ?
You need to set the pin P0_4 as interrupt with FALLING_EDGE to reset the state of P6_3, then configure the input of TCPWM block for start ( falling-edge ) and reload ( rising edge ). 
TCPWM need to start the counter when get the input pressed of button ( falling-edge ) then will reload the counter to 0 when button is released ( rising edge )

ADSW_0-1699448968313.png
Please find the code in attachment. 
To change the value of counter ( period ), you can use Cy_TCPWM_Counter_SetPeriod function.

Warm regards,
Andri

 

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

Andri,

Thanks for the fast response! Such great support!

I will check out the project later today.

The attached waveforms explain the behavior I am looking for. I took a quick look at your example code, and I think it will need some tweaking to match the waveforms I attached. Would you be able to update your example?

0 Likes
lock attach
Attachments are accessible only for community members.
ADSW
Moderator
Moderator
Moderator
250 sign-ins 50 solutions authored 25 likes received

Hello @MaLe_297531 ,

Apologize me for my late response. 

You can use add & configure TCPWM as square wave generator. 
Connect the Square wave signal to the counter input and output pins. 

ADSW_0-1699601229205.png


Warm regards,
Andri



0 Likes
lock attach
Attachments are accessible only for community members.
MaLe_297531
Level 2
Level 2
10 sign-ins 5 replies posted First like received

Andri,

I built your project, and the LED output is stuck low (LED on all the time). The board still works when I program with your previous example program. Any ideas of what could be wrong? I changed the LED pin to P6[3] which is the red LED.

-Mark

0 Likes
lock attach
Attachments are accessible only for community members.
MaLe_297531
Level 2
Level 2
10 sign-ins 5 replies posted First like received

Andri,

I figured out my solution. A screenshot of the schematic is attached. The code is below.

The pulses come out on the Red LED pin. When SW2 is pressed, N pulses are generated, then wait for the next button press.

The code is very simple.

#include "project.h"

int main(void)
{
(void) Cy_TCPWM_PWM_Init(PWM_HW, PWM_CNT_NUM, &PWM_config);
Cy_TCPWM_Enable_Multiple(PWM_HW, PWM_CNT_MASK);
Cy_TCPWM_TriggerStart(PWM_HW, PWM_CNT_MASK);

(void)Cy_TCPWM_Counter_Init(Counter_HW, Counter_CNT_NUM, &Counter_config);
Cy_TCPWM_Enable_Multiple(Counter_HW, Counter_CNT_MASK);
Cy_TCPWM_TriggerStart(Counter_HW, Counter_CNT_MASK);

for(;;)
{

}
}

ADSW
Moderator
Moderator
Moderator
250 sign-ins 50 solutions authored 25 likes received

Hello @MaLe_297531 , 

Thanks for your update and information. 
I'm glad to know your issue has been resolved, 
Then I will close this thread, 

 If you have any other issue in the future, please kindly do not hesitate to reach us again.

Warm regards,
Andri



0 Likes