Hi,
I need the ability to look through all the IO bits. I would like an array I can index to loop through each bit, starting at PORTA, absolute 80, bit 1 through PORTE, last bit.
Something like:
Dim PORTbits(40) as bit absolute 80
Can I do this to read and write to each bit.
birtong
Port Bits Structure
Moderators: David Barker, Jerry Messina
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
You can address individual bit in a port like this
but this will not set TRIS bits for you. In addition, it will not automatically "read from port, write to latch". If you want to iterate through each port and set a bit, use something like:
which will set 8 bits at a time. Using POSTINC will increment the address for the next port. To read, use something like AddressOf(PORTA). Note that when writing, you will need to set the direction bits for a port. Also, check the datasheet and make sure any register addresses are contiguous.
Code: Select all
PORTB.Bits(index)
Code: Select all
FSR0 = AddressOf(LATA)
POSTINC0 = <byte value>