Hi, I'm using a MCB2100 dev board with LPC2129 chip. I am used to using a 8051 based chip and have used the sbit declaration for pin assignment previously. However it doesn't really like it with my new board. How do I go about reading from an individual pin? thanks Andy
Thanks, but how do I read from a specific pin? For example if I was to connect a switch to P0,6 then how would I read from that pin without considering what all the other pin values are on that port? IOPIN0 would equal 0x00000040 when just that pin was high, but what if the other pins were high as well? thanks, andy
"how do I read from a specific pin?" Strange as it may seem, the 'C' programming language has nothing for manipulating individual bits! The 8051 has some special bit-addressable hardware, so Keil added extensions in C51 to use it; in the absence of such extensions, you will just have to use the standard 'C' techniques of masking with the bitwise operators.
if (IOPIN0 & 0x0000040) tests PIN0.6 for high. It reads also other pins, but the AND mask effectively ignors them.