-
1. Re: global variable function wait loop PSOC4M
user_302041 Aug 26, 2017 2:52 PM (in response to user_302041)Another thing I cant find an explanation to why would the program crash if I am running LCD commands in them In other programs in Psoc 42xx it worked great...
thanks
-
2. Re: global variable function wait loop PSOC4M
JoMe_264151 Aug 27, 2017 3:28 AM (in response to user_302041)1 of 1 people found this helpfulThere are some pitfalls I can see.
A global variable that is changed within an interrupt handler must be declared as "volatile". Otherwise a test within a loop (as in your case) might get optimized out.
There is no need to access your variable "ready" using a pointer. You may of course test it directly as if(!ready) ...;
So use: volatile uint8 ready = 0;
Even better because better readable might be
typedef uint8 Bool;
#define FALSE 0
#define TRUE !FALSE
volatile Bool ready = FALSE;
...and later...
if(!ready)...
...or...
Bool status()
{
return ready;
}
Disabling the interrupt within its handler is bad practice and is not needed. There is an interrupt queuing mechanism within the ICU (Interrupt Controller Unit) that handles that.
Not quite sure which Cypress kit you are using: CY8CKIT-043?? The I2C pins are different from yours.
Bob
-
3. Re: global variable function wait loop PSOC4M
user_302041 Aug 27, 2017 7:45 AM (in response to user_302041)Thank you BOB,
I also found yesterday that I was not using
CyGlobalIntEnable;
so that was a larger issue.
thanks for the tips will keep working on this.
Any Ideas why would the program crash when calling LCD funtions inside a function (this same line function) some commands are commented inside the while loop. LCD works just fine on the main block
the kit I am working on is CYC8CKIT-044 kit
-
4. Re: global variable function wait loop PSOC4M
JoMe_264151 Aug 27, 2017 8:06 AM (in response to user_302041)1 of 1 people found this helpfulThis behavour let me assume a stack problem.
And I found
sprintf(msg, "X:%.2f",Xcurr ); with msg holding 7 bytes. Can you be quite sure that Xcurr is always < 10??
The perfectly killing line is
sprintf(msg,"%.3f %.3f ",xlast,ylast); which will overwrite data even when xlast and ylast == 0.
Bob