Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

ByteCraft C compiler bitwise operations

ByteCraft C compiler bitwise operations

Anonymous
Not applicable
Answer: Question: The ByteCraft C compiler doesn't correctly do bitwise operations on the port data registers?  What is the reason?

Response: When performing an IORD on the port data registers, you are actually reading the voltage on the port pins themselves, not the value written to the register. CYDB uses an IORD instruction to display register values in the I/O Register window, so again the value displayed for the data port registers pertains to the voltage on the port pins.When using the ByteCraft C compiler you need to pay special attention to the following:
When writing C code and you try to set a bit in a port data register i.e. PORT0.0 = 1, the code has no way of reading the Port0 register's present value and only manipulating a single bit. You can't say Port0 = Port0 | 0x01 for example.  What would really happen instead is Port0 = (Voltages on Port0 pins) | 0x01. Instead you should keep a shadow register of the port data registers.


0 Likes
192 Views
Contributors