- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an application that is getting stuck when I try to access a static variable from within my isr. The interrupt is working and at a periodic interval (1 millisecond) the isr is incrementing a static variable inside that file. If I reference that variable directly in the sysTickDelay function there is no problem, BUT if I access it using a getSysTick function then my application gets stuck. I've used this same technique before on other micros and it has worked, not sure what I am doing, or have configured differently here that it is not working on my PSoC4 application.
Thanks.
/* Variables
-------------------------*/
static uint32_t oneMsecTick = 0;
/**
* @brief This function is called from the SysTick ISR every millisecond.
* It increments a variable to be used as a consistent time base.
*
* @param None
* @retval None
*/
void sysTickIncrement( void )
{
oneMsecTick++;
}
/**
* @brief Provides access to SysTick variable value in milliseconds.
*
* @param None
* @retval Tick value
*/
uint32_t getSysTick( void )
{
return ( oneMsecTick );
}
/**
* @brief Provides a blocking delay in millisecond.
*
* * @param delay_mSecs : specifies the delay time length, in milliseconds.
* @retval None
*/
void sysTickDelay( uint32_t delay_mSecs )
{
uint32_t timeDelay = getSysTick() + delay_mSecs;
while( getSysTick() < timeDelay )
{
// feedTheWatchDog(); /* Refresh the watchdog timer */
uint32_t count = 0;
count++;
}
}
Solved! Go to Solution.
- Labels:
-
PSoC 4 Architecture
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can refer to the below KBA
https://community.cypress.com/docs/DOC-15425
Regards,
Alakananda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Correct to
static volatile uint32_t oneMsecTick = 0;
The volatile keyword instructs the compiler that the variable is subject to sudden changes and should not be optimized.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can refer to the below KBA
https://community.cypress.com/docs/DOC-15425
Regards,
Alakananda