Programming, for all ages and all languages.
-
kubeos
- Member
- Posts: 138
- Joined: Tue Jan 30, 2007 2:31 pm
- Location: Kamloops BC, CANADA
-
Contact:
Post
by kubeos »
Here's my code:
Code: Select all
int getch()
{
char timewaster[5];
result=0;
do{
result=asckey;
if(result!=0)
{
asckey=0;
return result;
}
//memset(timewaster,0,5);
}while(1);
}
Now, it works fine when the memset line is UNCOMMENTED.. but when I do comment it out.. it doesn't work? Does anyone who is good with C have an idea?
PS. asckey is in my kb isr, which seems to be fine.. if you want me to post that too.. i will. result and asckey are both global vars.
Thanks for any replies.
-
frank
- Member
- Posts: 729
- Joined: Sat Dec 30, 2006 2:31 pm
- Location: East Coast, USA
Post
by frank »
Try making asckey and result volatile.
ie
-
kubeos
- Member
- Posts: 138
- Joined: Tue Jan 30, 2007 2:31 pm
- Location: Kamloops BC, CANADA
-
Contact:
Post
by kubeos »
Wow, that fixed it... thanks!!
I'll have to see if there's a parm that I can pass to gcc to stop optimizations.
-
frank
- Member
- Posts: 729
- Joined: Sat Dec 30, 2006 2:31 pm
- Location: East Coast, USA
Post
by frank »