- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content