Anonymous
Not applicable
Dec 01, 2015
08:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 01, 2015
08:44 PM
Hi, I don't want to psoc automatically optimize my code, how should I do?
My code as following,
WORD GetMsCount()
{
WORD tmpCount;
do
{
tmpCount = msCount;
}
while(tmpCount != msCount);
return tmpCount;
}
1 Reply
Dec 02, 2015
12:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 02, 2015
12:56 AM
Since msCount seems to be changed within an interrupt handler do not forget to declare it as "volatile"!!
In Project -> Build Settings -> Compiler -> Optimization you may set "Optimization Level" to "None", this setting is best for debugging.
Without the "volatile" attribute your while-loop would be prone to optimizatin taking tmpCount != msCount out of the loop because it does not change, leaving an infinite loop behind.
Bob