Slave code runs motors briefly out of reset

Hi All,

I am using the slave code in my 3pi, and I’ve foud that when i put the AVR in reset using the reset pin on the ISP header, the motors run momentarilty when I release reset. Does this happen for everybody else or am i “special” somehow ? :slight_smile:



Can you explain in more detail how you have things connected? Do you just have a single wire going from your master controller to the reset pin in the ISP header?

Can you cut your code down to the simplest program that demonstrates the problem and post it?

- Ben

Hi Ben,


I have GPIO attached to the MOSI, MISO, SCK and nRESET pin onthe 3pi ISP header. Common ground too.

My code uses a GPIO to pull the nRESET low, holds it low for 500ms then releases it. On release, the right motor pulses momentarility. My guess is that the motor is on until the AVR configures the motor control pins and sets them to the “off” state.

My code look is below. I get a small pulse on the right motor every 2 seconds.

#include "mbed.h"

DigitalOut nreset_avr(p8);
DigitalOut led(LED1);

int main() {
    while (1) {

        nreset_avr = 0;  // put AVR in reset
        led = 1;
        wait (0.5);      // wait for 100ms
        nreset_avr = 1;  // Bring AVR out of reset
        led = 0;
        // This is where we see the momentary pulse on the right motor
        wait(2.0);       // wait 2 seconds, and repeat



Does the code on your AVR run the motors immediately on reset? That is, do you get the same behavior with your other board disconnected just by pressing the reset button on the 3pi? If not, does it happen with ONLY the reset line connected to your board?

Also, I can’t tell from your code, but are you driving the reset pin to 3.3V or just releasing it and letting it get pulled up to 5V?


Hi Paul,

Done some more experiments and here . If i dont have my MCU hooked up to the board at all, then i dont see this behaviour, but with the MCU plugged in, i see this behaviour just by pressing reset button onthe 3pi.

unplugged my SPI connection to the 3pi, tried again (with the 3pi reset button) and I dont see this behaviour, so it must be something to do with the GPIO hooked up to the AVR ISP port.

Looking at the schematics, it seems that the the SPI port used for ISP has other functions when not in reset. Namely motor control.

I looked at my code, and saw that by default the GPIO pins hooked up to the ISP port are inputs with a pull down. I’ve set them to to be high impedance, and the reset motor pulse goes away (yay!).

I’d say that straight out of reset the AVR pins are high impedance, or have a (weak) pull up, and that my pull down was enough to activate the motors. When code executes on the AVR which sets up the IO to output, and drive it high, my pull down is over ridden and the motors switch off.

So, case closed. Thanks for asking the right questions!