Skip to content

6. Embedded programming

This week is about programming microprocessors starting from RP2040 board from week 04.

Group assignment:

  • browse through the data sheet for your microcontroller
  • compare the performance and development workflows for other architectures

Individual assignment:

  • write a program for a microcontroller development board that you made, to interact (with local input &/or output devices) and communicate (with remote wired or wireless devices)
  • extra credit: use different languages &/or development environments
  • extra credit: connect external components to the board group assignment:

Tools: Arduino IDE, Thonny & Micropython

Materials: PCB, electronic components, microprocessor

The group assignment

We are going to use RP20240 microcontroller on the Quentorres board we have produced for week 4.

Programming in Micropython

Install Thonny IDE Thonny is an Integrated Development Environment dedicated to learning Python language and embedding programming. It supports dedicated variants of Python language for microcontrolles such as Micropython and CircuitPython.

Actually to install Thonny for RP2040, see the instructions on Seeed help page on has to choose a few options: interpretor kind, MicroPython’s family, variant and version see the screen below.

Thonny installation

I run the first programme saving the code in the editor and pushing the Run current script button.

from machine import Pin, Timer

led = Pin(25, Pin.OUT)
Counter = 0
Fun_Num = 0

def fun(tim):
    global Counter
    Counter = Counter + 1
    print(Counter)
    led.value(Counter%2)

tim = Timer(-1)
tim.init(period=1000, mode=Timer.PERIODIC, callback=fun)

Error

Device is busy or does not respond. Your options: - wait until it completes current work; - use Ctrl+C to interrupt current work; - reset the device and try again; - check connection properties; - make sure the device has suitable MicroPython / CircuitPython / firmware; - make sure the device is not in bootloader mode.

The sequence of booting/reseting is a bit fuzzy now, also the

The design of the robot control board

Producing the board

Testing

Simulating the board

SVG-PCB

References

Fab people followed for this lesson

Info and tutorials

Dictionary

  • UART:
  • Microprocessor (chip) designates a processing unit while a Microcontroller it can be thought as a system on chip containing additionally to the processing unit and memory and IO ports https://www.geeksforgeeks.org/whats-difference-between-microcontoller-%c2%b5c-and-microprocessor-%c2%b5p/
  • development board
  • module
  • Xiao actually means: small, briefly, the young, for a short while, little. See pronunciation here
  • Seeed Studio XIAO Series (including RP2040) are diminutive development boards, sharing a similar hardware structure, where the size is literally thumb-sized.

Files