I' m very new in C programming but very old in assembly, basic and pascal. I desided to learn C. I use the IAR C Compiler.
My program has a lot of modules, each one with it's own .h file and .ext file.
I have defined the unsigned char TimeFlags as an external variable.
I have name the 1st bit us TimerInterruptFlag.
I have extern the definitions in order to be known from the other modules in the project.
When it interrupts I set this bit using a macro:
SetBit (TimeFlags, TimerInterruptFlag);
In another module waiting for the interrupt finished:
ClrBit (TimeFlags, TimerInterruptFlag);
while ((TimeFlags & 0x01) == 0x01);
Then I found that the programs is always loop at the last command (while).
In disasembler I see that in the while the program poles r16 and not TimeFlags. I see that r16 has the value of TimeFlags just before the interrupt.
Then I changed the variable as char (and not unsigned char) and everything works OK.
I read the C language and I am a little bit comfused with the pointers. Does anybody can tell me the diferrences between:
a) unsigned char *p, *pk;
unsigned char k=100;
p = &k;
*p = &k;
b) p = pk;
*p = *pk;