shiftout speed
How quickly does a shiftout send bits? If the doc describes this, I missed it.
Is there any way to do shiftout as a VP? It would be wonderful to be able to throw bits at a VP and have them sent in the background, just like a serial port...
Is there any way to do shiftout as a VP? It would be wonderful to be able to throw bits at a VP and have them sent in the background, just like a serial port...
Comments
However, the limiting factor is the ram access time. I have found that for
tansmitting a stream of bytes, the throughput is limited to about 10k·baud
(or 1000-1200 bytes per second).
Try timing to read an array of 10000 bytes like
char[noparse]/noparse myarray = new char[noparse][[/noparse]10000];
char c;
for (int i=0; i<10000; i++) {
· c = myarray[noparse][[/noparse]i];
}
and you find the maximum throughput.
regards peter
Regarding the ShiftOut/ShiftIn, do we have a way to slow it? It's a native methode, so I was not able to check it.
If we can't slow it, do we have a way to reproduce this methode by software?
Thanks,
JM
a shift function.
void ShiftOut(int clkPin, int dataPin, int value, int bits, int mode) {
· boolean clkState = CPU.readPin(clkPin);
· //mode CPU.SHIFT_LSB·is assumed here
· for (int i=0; i<bits; i++) {
··· boolean bit = (value & 0x0001) !- 0;
··· CPU.writePin(dataPin,bit);
··· CPU.writePin(clkPin,!clkState);
··· CPU.writePin(clkPin,clkState);
··· value >>= 1;
· }
}
You'll just have to figure out when to raise and lower the clockpin
according to mode (CPU.SHIFT_LSB, CPU.SHIFT_MSB).
For ShiftIn() you can create a simular function.
regards peter
I will use that, do the same for shiftIn and add some delay between the clkPin stats changes.
Regards,
JM