Hello, I am a student and currently working with AT89C2051. I'm new to this microcontroller. I,m using it in a circuit in which I need to compare a variable analog input to reference voltage using analog comparator of AT89C2051. I need to perform some operations in accordance with the logical output of comaprator. But I've stuck on it and don't know how to use this analog comparator. Please provide me the complete details/ C-code to perform this ASAP..
"Please provide me the complete details/ C-code to perform this ASAP.."
Why should we do this ASAP? Maybe we think it's better to break for food ASAP?
Have a look at the Atmel Application Notes.
lmgtfy.com/
I have already done a lot of search on internet including ATMEL's notes. But they have only mentioned about the pin configuration for this, But I want to know how to use it practically using a C program..
You say you are a student. But it doesn't seem you have too big interest in studying.
You want a C program that already does the task. Programming is normally about finding out what to do, and then implement a C program that fulfill the requirements. Why don't you want to write that C program yourself, as a real student should?
I don't want the complete C code. I just want to know that how to configure the analog comparator in C.
And you really did not find any information about how to configure the analog comparator? The world is void of such information?
To answer you question directly.
Yes you'll be fine. If you write a value to a port that is the same as the existing value nothing will happen on the output of the pin. It will stay at the same level and you will not see any disturbances.
That said be careful with using PORT when writing and reading. Typically you should write to the PORT and read from the PORT. You can have some funny race conditions if you write to the PORT because of how the processor does read/modify/write to the port bits.
You can have some funny race conditions if you write to the PORT because of how the processor does read/modify/write to the port bits.
I have worked with the '51 for decades and never seen that
Erik
Now I've understood this and even have developed the program for this.. Thanks for your suggestions !!