I have a quick question:
Suppose I have the following code:
DDIR = 0;
Now, I have a code that does some task and according to some conditions, the following line might be executed:
Code:
PORT1 &= ~(0x01 << 4);
The 5th pin of PORT1 is already 0, or low, whatever, when I write 0 to this pin, which is already 0, what will happen? is it going to write 0 again, or just the code ignores it and keeps it 0? Should I test the pin status before I write an existing status, don't laugh at me, but really this question has been on my head for a long time.
It depends entirely on the specific hardware - which you have chosen not to mention.
What does the Data Sheet tell you?
If something magic happens when you say to the processor to set a pin low and the pin was already low: then the user manual/datasheet for the processor will tell you so.
If the user manual/datasheet doesn't tell you about any magic, then the processor will just continue to keep the pin low - i.e. the extra "set pin low" will not make any difference except consume the expected number of clock cycles.
thanks per westermark.
i worry if the port has a fast pulse or spike(?) when i do it. you understand? like it goes hi and low again very quickly,.
And that would be "magic" that a chip manufacturer would need to document very clearly since that would break loooots of programs.
that would be "magic" that a chip manufacturer
the REAL magic would be that anyone could give a definite answer without knowing whar DDIR is and, most important which chip the OP uses.
Erik
you can close this thread.
Mr Per Westermark has given me a satsifasctorary answer.