I've been going through the bitbang code trying to figure out why I'm not getting any output (have BP hooked up to a scope) and came across this piece of code:
}else{//get LSB first
tem=tem<<1; //shift data output bits
dat=dat>>1; //shift the data input byte bits
if(di)dat+=0b10000000; //if datapin is HIGH, set MSB
}
My mind feels like mush ATM but am I correct in saying the shift in tem should be the other way round for LSB? Right now a null is shifted in at the LSB position and output in the next stage.
Even if this is a bug it doesn't solve my problem since I'm using MSB First so I'm still searching.
Thanks for the bug report. I think you're right, it is shifted the correct was in the 2wire function. I updated it and committed the changes. Here's the code in SVN:
http://code.google.com/p/the-bus-pirate ... bang.c#133 (http://code.google.com/p/the-bus-pirate/source/browse/trunk/source/bitbang.c#133)
Though what is the other problem you're having? Maybe I can help with it.
I'm trying to send the BP a cont data stream at 5K to output in the raw 3 wire bin mode, I have to do partial sends to prevent overrunning the BP buffer though I'm still not sure If I can actually reach this throughput.
What I'm doing now is completely ignoring the clock line and taking continuous samples using the raw 3 wire bulk read command (I completed this command and attached a patch) saving these and playing them back later, when playing them back I only get portions due to the throughput problem but this doesn't bother me that much, the problem is that the data that I do get through is distorted, possibly due to using the 3 wire mode in this fashion.
The pic I've attached shows what is supposed to be a square wave but the portions marked in red have discontinuities, they should be completely low. Any ideas? (I've checked the data I send and it is correct, it is distorted by the BP to give the discontinuities)
It really has me curious what is going on. I rechecked the bbio output code and didn't see anything that should be doing that, though we do set the pin direction a lot so it's always right in 2 wire modes. I'll run it on a logic analyzer at max speed and see what I get.
I've been over the bb code a number of times and this just shouldn't be happening, I'm taking a shot in the dark here but is there some type of interrupt firing on serial events, when the buffer is overrun for example?
As far as I know, there are no interrupts used in the Bus Pirate firmware besides the OpenOCD functionality. On a buffer overrun, I believe the MODE LED goes out, or something. Someone mentioned previously it'd be better to just stop so you know when the data is corrupt, maybe that's something I should change for the next release (I realize it's not related here).
Looks like the line is released to HiZ when the bit toggles.
Just wondering is the level 0 when the clk goes high or is high? (most chip triggers on this and read the data in when triggered)