MicroMod STM32 Processor Hookup Guide

Pages
Contributors: Alex the Giant, Ell C
Favorited Favorite 0

Examples

Blink

Let's start with something basic - let's blink an LED. Go to File->Examples->01.Basics->Blink.

Blink Basics Example in the pulldown

Having a hard time seeing? Click the image for a closer look.


Once you've plugged your MicroMod Carrier Board with your MicroMod STM32 Processor into your computer, you'll need to go to your Tools menu and set up your options to look like the following:

Tools menu with STM32 Options

With everything setup correctly, you'll need to put the Carrier Board into Boot Mode in order to upload the code.

  • Press and hold down the Boot button
  • Press and release the Reset button while continuing to press the Boot button
  • Release the Boot button and press the Upload button in your Arduino IDE

Once the code finishes transferring, you should see the STAT LED on the STM32 Processor Board begin to blink!

Status LED on the STM32 MicroMod Processor Board is blinking

If the blue LED remains dimly lit, it's probably still sitting in the bootloader. After uploading a sketch, you may need to tap the RST button to get your STM32 MicroMod Processor Board to begin running the sketch.

I2C Scanner

The Qwiic Connect Ecosystem makes attaching sensors a breeze. That said, sometimes it's nice to be able to scan your I2C connections to find out the address of your sensor. That's what we'll do here!

Grab your MicroMod STM32 Processor Board and your Carrier Board, and attach a Qwiic Sensor to the Qwiic port on the Carrier like so:

STM32 Processor Board, Carrier Board, and Qwiic sensor attached

Copy and paste the code below into a new Arduino sketch.

language:c
// --------------------------------------
// I2C Scanner example using Wire1
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>

TwoWire Wire1(SDA1,SCL1); //Intialize Wire1 class

void setup()
{
  Wire1.begin();

  Serial.begin(115200);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire1.beginTransmission(address);
    error = Wire1.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

Make sure your options are all set up correctly in the Tools menu, and make sure you put the Carrier Board into Boot Mode in order to upload the code.

  • Press and hold down the Boot button
  • Press and release the Reset button while continuing to press the Boot button
  • Release the Boot button and press the Upload button in your Arduino IDE

After uploading, open the serial monitor and set the baud to 115200. You should see a similar printout to the one shown below.

GIF of screen monitor showing that the qwiic sensor has been found and address 0x48

UART Example

Let's have a quick look at an example using UART. If you're unfamiliar with Serial Output, go ahead and have a look at our Serial Basic Tutorial.

Grab your MicroMod STM32 Processor Board and your Carrier Board, and attach the Serial Basic Rx and Tx pins like so:

MicroMod ATP board with Serial Basic RX and TXX pins hooked up

Click on the image for a closer view

Copy and paste the code below into a new Arduino sketch.

language:c
// --------------------------------------
// UART example using Serial1
//
//
// This sketch prints "Hello World!" every second
// using the secondary UART pins RX1 and TX1.
//



HardwareSerial Serial1(RX1, TX1); //Attach Serial1 to RX1 and TX1

void setup() {
  Serial1.begin(115200);
  while (!Serial1) {
    ; // wait for serial port to connect. Needed for Native USB only
  }
  Serial1.println("Goodnight moon!");

}

void loop() {
  Serial1.println("Hello World!");
  delay(1000);
}

Make sure your options are all set up correctly in the Tools menu, and make sure you put the Carrier Board into Boot Mode in order to upload the code.

  • Press and hold down the Boot button
  • Press and release the Reset button while continuing to press the Boot button
  • Release the Boot button and press the Upload button in your Arduino IDE

Once your code is uploaded, open up the Serial Monitor attached to your Serial Basic with the baud rate set to 115200 to see your output!

Gif of the serial output printing "Hello World" every second