|
Bob, I should have explained my setup better. The code posted actually executes within a timer that get's fires every 2s. I'm not concerned about previous values for this test. I'm treating all pins on the port as output and the code should simply read the number of bits that are high then turn off the high bit so that the LEDs cycle from 8 pins high to 7, 6, 5...0, 8... I'm familiar with the shadow register technique but I don't think that applies here. Correct me if I'm wrong.
If I change the (C#) code slightly to this...
var timer = new GT.Timer(2000);
timer.Tick += timer1 =>
{
const byte PORT = 7;
io60p16.SetPortMode(PORT, PORT_DRIVEMODE.RES_PULLDOWN);
io60p16.SetPortDirection(PORT, 0xff);
byte v = io60p16.GetPortOutput(PORT);
if (v == 0) v = 0xff;
else v = (byte)(v >> 1); // cycle through the pins...
io60p16.SetPortOutput(PORT, 0x00);
io60p16.SetPortOutput(PORT, v);
Thread.Sleep(500);
byte n = io60p16.GetPortOutput(PORT);
Debug.Print("Setting to: " + v + "\tReads as: " + n);
};
timer.Start();
Then I get this output...
Setting to: 255 Reads as: 255
Setting to: 127 Reads as: 127
Setting to: 127 Reads as: 127
Setting to: 63 Reads as: 63
Setting to: 31 Reads as: 31
Setting to: 15 Reads as: 15
Setting to: 127 Reads as: 255
Setting to: 63 Reads as: 63
Setting to: 31 Reads as: 31
Setting to: 15 Reads as: 15
Setting to: 7 Reads as: 7
Setting to: 3 Reads as: 3
Setting to: 1 Reads as: 1
Setting to: 0 Reads as: 0
Setting to: 255 Reads as: 255
Setting to: 127 Reads as: 127
Setting to: 63 Reads as: 255
Setting to: 127 Reads as: 127
Setting to: 63 Reads as: 63
Setting to: 31 Reads as: 31
Setting to: 15 Reads as: 255
Setting to: 7 Reads as: 7
Setting to: 3 Reads as: 3
Setting to: 1 Reads as: 1
Setting to: 0 Reads as: 255
Setting to: 255 Reads as: 255
Setting to: 127 Reads as: 127
Setting to: 63 Reads as: 63
You can see that in most cases the values being written are also be read back correctly. However, none of my LEDs lighting. I should also note that if I first enable all the pullup resistors for the port before doing the pulldown then they will all light up. So, I know there's not a wiring problem.
Am I not fully understanding what you're telling me or is there really something weird going on here?
|