Setting multiple pins simultaneously


Author Message
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 449
Posted: 04:36pm 12 May 2025      

Mmmmm curious behaviour (most likely something I am doing)

Version 6.0001 -- plain old Mite via serial terminal.  Fresh flash.

Testing with x4 leds, GP2-GP5

PORT(gp2,4) = &B1111  indeed turns on all 4 LEDS
PORT(gp2,4) = &B0000  does not turn the leds off

Reissuing PORT(gp2,4) = &B1111 turns off the LEDs.

It looks like setting a bit to "0" is not turning off, but setting to "1" toggles the state between 0 and 1 back to 0.


Print "Starting..."
Print "ALL on"
Port(gp2,4) = &B1111
Pause 1000
Print "All off"
Port(gp2,4) = &B0000  'Looks like it does nothing - ie LEDS still lit
Pause 1000
Print "Trying &B1111"
Port(gp2,4)=&B1111    'indeed turns off LEDS
Pause 1000


Therefore once the bit pattern is not all 1111's or all 0000's issuing PORT(GP2,4) = 1 << Rnd * 3  as per this thread only turns off leds once they recive a "1" ie turn off when already on.

This is most likely something I am doing...... any pointers...

Cheers
Edited 2025-05-13 02:42 by Nimue