MSP430 Motor Driver Boosterpack

I’ve designed various versions of a Robot or Motor Driver boosterpack, but this is the first one I’ve actually produced the PCB for. This board features support for:

  • L298 motor driver (2 x 2A motors) – one of my favourites
  • 3 servo connections
  • External connectors for sensors
  • 3 sub-boards, not yet tested. One proximity sensor, one with two buttons and one for an RGB LED and a photo-sensitive resistor.

Here’s a picture of the board:

Board layout and code below.

The Eagle files are here. License  = Creative Commons Attribution-ShareAlike 3.0 Unported License. The schematic is missing diodes. It should really have diodes across the motor outputs to protect the electronics on the board.

The code is below. If you want the motor to not be on 100% power, you can implement a PWM signal on the enable pins. This can be done by using the timers directly (most efficient) or by having the timer call in interrupt and setting the enable pin on/off there at certain intervals. The code below shows the watchdog-timer, but it’s been disabled. You can enable it in the top of the code and then implement a PWM signal inside the interrupt routine on the bottom.

[code lang=”c”]

* Author: Lars Kristian Roland, APUS
* Copyright & all rights reserved: APUS

#include <msp430.h>

#define ENB BIT0
#define ENA BIT1
#define IN1 BIT0
#define IN2 BIT1
#define IN3 BIT2
#define IN4 BIT3
#define IN_OUT P2OUT
#define EN_OUT P1OUT
#define IN_DIR P2DIR
#define EN_DIR P1DIR
#define A_FORWARD IN_OUT &= ~IN2; __delay_cycles(30000); IN_OUT |= IN1;
#define A_BACKWARD IN_OUT &= ~IN1; __delay_cycles(30000); IN_OUT |= IN2;
#define B_FORWARD IN_OUT &= ~IN3; __delay_cycles(30000); IN_OUT |= IN4;
#define B_BACKWARD IN_OUT &= ~IN4; __delay_cycles(30000); IN_OUT |= IN3;

void main (void)
//WDTCTL = WDT_MDLY_8; // Call watchdog interrupt every 8ms
//IE1 |= WDTIE;

// Set up port IO
IN_DIR |= IN1 | IN2 | IN3 | IN4;

P1REN &= ~BIT3;
P1OUT |= BIT3;

//EN_OUT &= ~ENA;

while (1) {
if (P1IN & BIT3) {
else {
// Watchdog Timer interrupt service routine
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
//EN_OUT ^= ENB;



2 thoughts on “MSP430 Motor Driver Boosterpack”

Leave a Reply

Your email address will not be published. Required fields are marked *