Quoted from raysco:Hi,
I am having a little issue running this code on a Altek mpu Trident.
I have a rev 1 board and have loaded the code which works fine but only if I press the reset button on the Arduino. It will not boot until I do this.
I have tried 2 boards and 2 nano with the same result.
I have a switch wire running to the base of the cab to switch between old and new code, but even jumpering it at the rev 1board doesnt make a difference.
Any thoughts?
i
It has been a while since the Rev 1 board, but we should be able to figure this out. I designed/tested that board on a stock MPU100, but since then plenty of people have used it on an Alltek, myself included. But, there is variation in MPUs... Anyway!
On the Rev 1, the Arduino doesn't have knowledge of the old-code/new-code switch position (I ran out of pins). Instead, the 74125 pulls the halt low to stop the 6800 from running. Then, the Arduino waits for a second, monitors the VMA line and only runs if the VMA line shows no activity. So, the switch halts the 6800, so it has no VMA activity, and then the Arduino sees no bus activity and runs.
My guess is that the Arduino is seeing spurious VMA activity and refusing to boot. By the time you hit the reset button, the activity is gone on the VMA line and it starts up. Here's how I would test this theory:
In BallySternOS.cpp, look for these lines:
void BSOS_InitializeMPU() {
// Wait for board to boot
delayMicroseconds(50000);
delayMicroseconds(50000);
Those delays are supposed to delay bootup for 100ms total, to allow the board to boot & settle. I used that function (delayMicroseconds) elsewhere in the code, so I used it here instead of delay(), which takes a value in ms. Long story short, only using one function saves code space, but this might be an issue. I just read that:
"Currently, the largest value that will produce an accurate delay is 16383; larger values can produce an extremely short delay. This could change in future Arduino releases. For delays longer than a few thousand microseconds, you should use delay() instead."
If that's still true, you could try replacing the two "delayMicroseconds(50000);" lines with seven lines of 16383, like this:
void BSOS_InitializeMPU() {
// Wait for board to boot
delayMicroseconds(16383);
delayMicroseconds(16383);
delayMicroseconds(16383);
delayMicroseconds(16383);
delayMicroseconds(16383);
delayMicroseconds(16383);
delayMicroseconds(16383);
If that still doesn't work, try 20 of those lines--put a nice long delay in there to allow things to settle before the Arduino makes its decision.
Or, if there's enough compile space in that code base (I can't currently check), try this:
void BSOS_InitializeMPU() {
// Wait for board to boot
delay(500);
If none of those things work, keep cranking the delay until it does? Either way, please keep me informed of your results!