Why, for HT49 LCD type MCU an input could be unexpectedly changed as an output after executing SET or CLR instructions?
Answer Usually this could happen when input and output lines are assigned in the same I/O port and the SET or CLR bit manipulation instructions are employed for output control. The SET and CLR bit manipulation instructions employ Read-Modify-Write operations, when used on I/O port, it will first read the entire port execute the defined bit operations and then write to I/O port. If the input line happens to be low externally on the line during Read phase, this input line will therefore to be read as 0 and write back to low and function as an output line. To avoid this situation, users are recommended to operate on the I/O Port RAM Buffer and then write the Buffer contents to I/O port.