hi C,
If want to avoid initialising 'simple' variables to zero within your program, tick the menu option.
I always prefer code initialising.
E View attachment 106689
hi C,
As you may know, when you power up your PIC, the memory area holding variables may or may not be cleared to zero.
[depending on whose compiler you are using]
So if you used 'x' as a indexing counter variable, it could be loaded with say 3 etc on power up.
So your increment would start at 3.
You can either
Dim x as a Byte ' then
x=0
or tick the pop up menu
I prefer to set variable values in the code.
E
hi C,
As you may know, when you power up your PIC, the memory area holding variables may or may not be cleared to zero.
[depending on whose compiler you are using]
So if you used 'x' as a indexing counter variable, it could be loaded with say 3 etc on power up.
So your increment would start at 3.
You can either
Dim x as a Byte ' then
x=0
or tick the pop up menu
I prefer to set variable values in the code.
E
Hi E,
I didn't know about clearing variables, I'll try to remember to tick the box, Thanks.
My version doesn't show 'Initialise variable under the OPTIONS drop down?
C.
Your picture of code with res1 and res2 were both comparing by > 0. That is why I said the ">" is irrelevant, you compare to 0 or 1 with an "=" instead to test the state of a bit.
I was referring to your original code, and trying to explain why I used "=" instead.
Your picture of code with res1 and res2 were both comparing by > 0. That is why I said the ">" is irrelevant, you compare to 0 or 1 with an "=" instead to test the state of a bit.
I was referring to your original code, and trying to explain why I used "=" instead.
It is sometimes useful to use the greaterthan comparison operator when testing bits other than zero when the compiler doesn't support bit types. If(var & 4 > 0) will work where as if(var & 4 == 1) will not. However, it's clearer to use if(var & 4 == 0) or if(var & 4 != 0). You can also use if(var & 4 == 4) as well. Hope I didn't confuse the subject even more.
Hi,
Here's a slightly updated version of yesterdays program. BITS and BYTES
I am sure there are mistakes, feel free to point any out.
I now have to understand how the FIFO works, to finish the program.
C.
It is sometimes useful to use the greaterthan comparison operator when testing bits other than zero when the compiler doesn't support bit types. If(var & 4 > 0) will work where as if(var & 4 == 1) will not. However, it's clearer to use if(var & 4 == 0) or if(var & 4 != 0). You can also use if(var & 4 == 4) as well. Hope I didn't confuse the subject even more.