Hi,
The following code in C# works but way to slow for our needs:
private void SendData(byte[] redData, byte[] whiteData)
{
for (byte i = 0; i < 128; i++)
{
ShiftOutData(redData[i], whiteData[i]);
}
stbPin.Write(true);
stbPin.Write(false);
}
private void ShiftOutData(byte redByte, byte whiteByte)
{
for (byte i = 0; i < 8; i++)
{
redPin.Write((redByte & 1) == 1);
whitePin.Write((whiteByte & 1) == 1);
clkPin.Write(true);
redPin.Write(false);
whitePin.Write(false);
clkPin.Write(false);
redByte >>= 1;
whiteByte >>= 1;
}
}
To make this faster, I figured I’d execute it as an RLP procedure:
void ShiftOutData(unsigned char byte0, unsigned char byte1)
{
char bit;
for (bit = 0; bit < 8; bit++)
{
RLPext->GPIO.WritePin(RED_PIN, (byte0 & 1));
RLPext->GPIO.WritePin(WHITE_PIN, (byte1 & 1));
RLPext->GPIO.WritePin(CLK_PIN, 1);
RLPext->GPIO.WritePin(RED_PIN, 0);
RLPext->GPIO.WritePin(WHITE_PIN, 0);
RLPext->GPIO.WritePin(CLK_PIN, 0);
byte0 >>= 1;
byte1 >>= 1;
}
}
int SendData(unsigned char *generalArray, void **args, unsigned int argsCount, unsigned int *argSize)
{
unsigned char *data0 = generalArray;
unsigned char *data1 = (unsigned char*)args[0];
char i;
for(i = 0; i < 128; i++)
{
ShiftOutData(data0[i], data1[i]);
i++;
}
RLPext->GPIO.WritePin(STB_PIN, 1);
RLPext->GPIO.WritePin(STB_PIN, 0);
return 0;
}
When I call this from C#, sometimes it works, sometimes it doesn’t.
Most of the time, the data is only written to the ports the first time,
after that nothing… unless I place a breakpoint on the RLP call, let VS pauze and then resume the application.
Any ideas what might be causing this kind of behaviour ?
So different behaviour when you put a breakpoint on the RLP call and when you don’t.
Also, I’m no C expert, perhaps I have a mistake in the C code
and it does not offer the same functionality as the C# code?
Thank you for your time