Dangerous Prototypes

Dangerous Prototypes => Bus Pirate Development => Topic started by: s3c on June 26, 2010, 02:38:07 am

Title: Bug in bbReadWriteByte?
Post by: s3c on June 26, 2010, 02:38:07 am
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:

Code: [Select]
		
}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.
Title: Re: Bug in bbReadWriteByte?
Post by: ian on June 26, 2010, 08:35:51 am
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)
Title: Re: Bug in bbReadWriteByte?
Post by: ian on June 26, 2010, 08:36:27 am
Though what is the other problem you're having? Maybe I can help with it.
Title: Re: Bug in bbReadWriteByte?
Post by: s3c on June 26, 2010, 05:34:08 pm
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)
Title: Re: Bug in bbReadWriteByte?
Post by: ian on June 27, 2010, 08:42:36 am
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.
Title: Re: Bug in bbReadWriteByte?
Post by: s3c on June 28, 2010, 12:05:21 am
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?
Title: Re: Bug in bbReadWriteByte?
Post by: ian on June 28, 2010, 08:11:36 am
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).
Title: Re: Bug in bbReadWriteByte?
Post by: Sjaak on June 28, 2010, 10:41:31 pm
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)

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01012061280session_write_close ( )...(null):0
20.01042192856ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01052193632Database_MySQL->query( ).../DatabaseHandler.php:119
40.05722332352Database_MySQL->error( ).../Db-mysql.class.php:273