Sporadic Failure of timer value, Bug?

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.
Anonymous
Not applicable
        Hello together, im working with a CY8CKIT-050. Sometimes I have the problem that the timer (32 bit udb) not count correctly. (example: 962945, 962688,962942). Is seems that sometimes a byte is not captured right. I've created a test Project where you can test this (stops on breakpoint when the Counter value is not okay). I assembled a new chip (80 MHz variant), but it has the same issue. I create a case, but until now I don't get a solution. I need the timer for the project of my company. Perhaps, somebody here can help me. Thanks and regards from Germany Patro   
0 Likes
1 Solution
Anonymous
Not applicable

Hi, I ran into this bug back in early march 2014 and got my local FAE involved. 

   

I was advised this problem was introduced with version 2.40 of the Timer component and also exists in version 2.50. 

   

(Note: versions 2.40 and 2.50 were in PSoC Creator 3.0 Component Pack 7)

   

2.40 was when the MISRA compliance was added to the component.

   

I was very much supprised and dissapointed when the fix to this bug was NOT included in PSoC Creator 3.0 SP1

   

Below is the code generated for version 2.30 of the component, The line in question is:

   

     CY_GET_REG8(Timer_REAL_TIME_COUNTER_1MHz_COUNTER_LSB_PTR); // correct version

   

/*******************************************************************************
* Function Name: Timer_REAL_TIME_COUNTER_1MHz_ReadCounter
********************************************************************************
*
* Summary:
*  This function returns the current counter value.
*
* Parameters:
*  void
*
* Return:
*  Present compare value.
*
*******************************************************************************/
uint32 Timer_REAL_TIME_COUNTER_1MHz_ReadCounter(void)
{

    /* Force capture by reading Accumulator */
    /* Must first do a software capture to be able to read the counter */
    /* It is up to the user code to make sure there isn't already captured data in the FIFO */
    CY_GET_REG8(Timer_REAL_TIME_COUNTER_1MHz_COUNTER_LSB_PTR);

    /* Read the data from the FIFO (or capture register for Fixed Function)*/
    return (CY_GET_REG32(Timer_REAL_TIME_COUNTER_1MHz_CAPTURE_LSB_PTR));
}

   

Below is the code generated for version 2.30 of the component, the line in question is:

   

         (void)Timer_1_COUNTER_LSB;

   

/*******************************************************************************
* Function Name: Timer_1_ReadCounter
********************************************************************************
*
* Summary:
*  This function returns the current counter value.
*
* Parameters:
*  void
*
* Return:
*  Present compare value.
*
*******************************************************************************/
uint32 Timer_1_ReadCounter(void)
{

    /* Force capture by reading Accumulator */
    /* Must first do a software capture to be able to read the counter */
    /* It is up to the user code to make sure there isn't already captured data in the FIFO */
    (void)Timer_1_COUNTER_LSB;

    /* Read the data from the FIFO (or capture register for Fixed Function)*/
    #if(Timer_1_UsingFixedFunction)
        return ((uint32)CY_GET_REG16(Timer_1_CAPTURE_LSB_PTR));
    #else
        return (CY_GET_REG24(Timer_1_CAPTURE_LSB_PTR));
    #endif /* (Timer_1_UsingFixedFunction) */
}

   

Also note, this same problem exists with the function

   

void Timer_1_SoftwareCapture(void)

   

 

   

 

   


 

View solution in original post

0 Likes
11 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

There is something I must be missing.

   

 

   

You start a timer, running continuously, simply being clocked, then

   

in a non deterministic loop keep reading it and get different values.

   

Thats normal ! The clock source is derived from a PLL, which has

   

jitter, the CPU is affected by other processes and asynch events.

   

 

   

If you are trying to measure an unknown inputs period you would

   

use a gate and run the timer during the gate, and stop it at end of gate

   

and read it.

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Workaround:

   

TIMER_Stop();
time = TIMER_ReadCounter();
TIMER_Start();

   

 

   

I ran your program on a PSoC4 and there was a discrepancy, too. Although it is a bit unusual to continously read the counter-value.

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        Hi together, thank you for your suggestions. I'm not reading the timer continuously in my normal program. I write this program only to simulate/ force the error which I get in my normal program sometimes. The clocks are synch, and the capture function of the datapath capture the values in the fifos. The Counter value is read from the fifos not from the Count register. Someone else have the same problem: http://www.cypress.com/?app=forum&id=2232&rID=77745 Thank you for the Workaround, it works. But it seems to me, that the capture to fifo function with synch not work properly.   
0 Likes
Anonymous
Not applicable
        If somebody has the same problem, here is the solution: (void)(* (reg8 *) TIMER_TimerUDB_sT32_timerdp_u0__A0_REG); must be called in the ReadCounter function, instead of (void)(* (reg32 *) TIMER_TimerUDB_sT32_timerdp_u0__A0_REG);   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

A wrong type cast? I've never thought of something like that!

   

Are you going to file a MyCase to inform Cypress so that this can be corrected for everyone?

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        Hi, cypress found the solution after i've created a case , so they are informed. Regards, Patrik   
0 Likes
Anonymous
Not applicable

Hi, I ran into this bug back in early march 2014 and got my local FAE involved. 

   

I was advised this problem was introduced with version 2.40 of the Timer component and also exists in version 2.50. 

   

(Note: versions 2.40 and 2.50 were in PSoC Creator 3.0 Component Pack 7)

   

2.40 was when the MISRA compliance was added to the component.

   

I was very much supprised and dissapointed when the fix to this bug was NOT included in PSoC Creator 3.0 SP1

   

Below is the code generated for version 2.30 of the component, The line in question is:

   

     CY_GET_REG8(Timer_REAL_TIME_COUNTER_1MHz_COUNTER_LSB_PTR); // correct version

   

/*******************************************************************************
* Function Name: Timer_REAL_TIME_COUNTER_1MHz_ReadCounter
********************************************************************************
*
* Summary:
*  This function returns the current counter value.
*
* Parameters:
*  void
*
* Return:
*  Present compare value.
*
*******************************************************************************/
uint32 Timer_REAL_TIME_COUNTER_1MHz_ReadCounter(void)
{

    /* Force capture by reading Accumulator */
    /* Must first do a software capture to be able to read the counter */
    /* It is up to the user code to make sure there isn't already captured data in the FIFO */
    CY_GET_REG8(Timer_REAL_TIME_COUNTER_1MHz_COUNTER_LSB_PTR);

    /* Read the data from the FIFO (or capture register for Fixed Function)*/
    return (CY_GET_REG32(Timer_REAL_TIME_COUNTER_1MHz_CAPTURE_LSB_PTR));
}

   

Below is the code generated for version 2.30 of the component, the line in question is:

   

         (void)Timer_1_COUNTER_LSB;

   

/*******************************************************************************
* Function Name: Timer_1_ReadCounter
********************************************************************************
*
* Summary:
*  This function returns the current counter value.
*
* Parameters:
*  void
*
* Return:
*  Present compare value.
*
*******************************************************************************/
uint32 Timer_1_ReadCounter(void)
{

    /* Force capture by reading Accumulator */
    /* Must first do a software capture to be able to read the counter */
    /* It is up to the user code to make sure there isn't already captured data in the FIFO */
    (void)Timer_1_COUNTER_LSB;

    /* Read the data from the FIFO (or capture register for Fixed Function)*/
    #if(Timer_1_UsingFixedFunction)
        return ((uint32)CY_GET_REG16(Timer_1_CAPTURE_LSB_PTR));
    #else
        return (CY_GET_REG24(Timer_1_CAPTURE_LSB_PTR));
    #endif /* (Timer_1_UsingFixedFunction) */
}

   

Also note, this same problem exists with the function

   

void Timer_1_SoftwareCapture(void)

   

 

   

 

   


 

0 Likes
Anonymous
Not applicable

OOPs correction to my previous post (a little one)

   

The instance of the Timer component "Timer_1" was based on version 2.50 of the Timer component (not 2.30 as I reported)

0 Likes
Anonymous
Not applicable

OOPs, reread what I wrote, and wish to add to it.

   

 

   

This problem does NOT exist in version 2.30 of the component, so my solution was to use this older version of the component in my design.  I did NOT follow up what features I am loosing by using this older component.

   

 

   

Chuck

0 Likes
Anonymous
Not applicable
        PSoC Creator 3.0 SP2 has fixed the problem in with Timer_ReadCounter() But the problem was not fixed in the function: Timer_SoftwareCapture()   
0 Likes
Anonymous
Not applicable
        For rev 2.60 of the Timer Component   
0 Likes