fx3s timer

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

cross mob
gean_3054931
Level 5
Level 5
10 likes given 5 likes given First like received

Hi,

How to generate one mili second using timer in fx3s?

thank you...

0 Likes
1 Solution
abhinavg_21
Moderator
Moderator
Moderator
50 likes received 25 likes received 10 likes received

Create a new callback function named say, Timercb()

CyU3PTimer Timer;     // define this handle

void TimerCb()

{

// Here you get the callback after  Time_in_millisecond

}

void TimerInit(void)

{

CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

apiRetStatus = CyU3PTimerCreate(&Timer, TimerCb, 0, Time_in_millisecond, Time_in_millisecond, 1);

if (apiRetStatus != CY_U3P_SUCCESS)

{

   CyU3PDebugPrint (2, "TimerCreate failed, Error Code = %d\r\n", apiRetStatus);

}

}

Note: For further understanding you can refer to CyU3PTimerCreate() API in API Guide

Regards

Abhinav

View solution in original post

4 Replies
abhinavg_21
Moderator
Moderator
Moderator
50 likes received 25 likes received 10 likes received

Create a new callback function named say, Timercb()

CyU3PTimer Timer;     // define this handle

void TimerCb()

{

// Here you get the callback after  Time_in_millisecond

}

void TimerInit(void)

{

CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

apiRetStatus = CyU3PTimerCreate(&Timer, TimerCb, 0, Time_in_millisecond, Time_in_millisecond, 1);

if (apiRetStatus != CY_U3P_SUCCESS)

{

   CyU3PDebugPrint (2, "TimerCreate failed, Error Code = %d\r\n", apiRetStatus);

}

}

Note: For further understanding you can refer to CyU3PTimerCreate() API in API Guide

Regards

Abhinav

lock attach
Attachments are accessible only for community members.

Hi Abhinav,

 

I'm trying to crate timer that call a function like in the example, but the it seems that the function don’t get called.

 

Ill attach the FW files and hope you can help me understand what is the problem.

 

Thanks,

EliW.

 

0 Likes
lock attach
Attachments are accessible only for community members.
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi EliW,

I found that you have not called the function TimerInit () in your code. Please find the attached project where I have added the relevant code. Also, it is not recommended to add Debug prints inside callback functions. So, I have used a global variable to check if the callback was invoked or not. Using these modifications, I can find that the timer callback function was invoked at my end. Please find the snapshot of the tera term below:

JayakrishnaT_76_0-1645413137348.png

 

Best Regards,
Jayakrishna

Thanks! it works!

EliW.

0 Likes