by Gabor Mandoki

Embedded Programming.


 

I already programmed my two boards successfully in the previous weeks.

Electronic Production.

Hello World Board.

Setting up Platform IO.

So I challenged myself for this week to switch from Arduino IO to Plattform IO and to program an SOS blinking with Python. I watched this video as a guideline to set everything up inside Atom.

It guided me through the essential steps and to understand how this would work.

Everything set up, I tried to import my Arduino code and settings from the week before. This made my hello echo board only blink when I pushed the button. I understood the file structure inside the platform IO and started to debug the code and the settings.

Here is some advice:

  • the file called main.cpp is a C file that you can compare to the code file in Arduino. Everything you would like to programme has to be written in here.

  • the plattform.ini file is the configutraion file where you can set the board, framework, upload port and so on. here are some things i used:

[env:attiny44]
platform = atmelavr
lib_extra_dirs = ~/Documents/Arduino/libraries
framework = arduino
board = attiny44
; change microcontroller
board_build.mcu = attiny44
; change MCU frequency
board_build.f_cpu = 20000000L
; upload_port & programmer
; upload_protocol = usbtiny
; upload_port = /dev/cu.usbserial-FT9P085Z

You can find some of the values like the MCU frequency in the datasheet.

Here are some sources from the platfrom IO docs:

upload port:

Upload options - PlatformIO 4.0.0a5 documentation

configuration for programmer:

Atmel AVR - PlatformIO 4.0.0a5 documentation

configuration for attiny44:

Generic ATtiny44 - PlatformIO 4.0.0a5 documentation

board options:

Board options - PlatformIO 4.0.0a5 documentation

It’s not working yet… I will continue as soon as I got through with troubleshooting. I would also like to work a bit with microPython.

SOS code.

This is the code to let the LED blink “SOS”.

#include <Arduino.h>

// const int buttonPin = 3;     // the number of the pushbutton pin
// const int ledPin =  7;      // the number of the LED pin

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(6, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(6, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(6, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Datasheet.

The datasheet, in general, is your starting point when you design a board. You can get the power, how the pins are arranged if it can do the job you want to have it for etc.

So I tried to find if I can use an ATTiny44 for MicroPython. So I looked for the minimum requirements for MicroPython and checked in the sheet how much memory the ATTIny has.

  ATTIny 44 microPython
Flash Memory 4k 128k
RAM 256BYTES 8KB

So the ATTiny is too small for micro Python. I have to try with another microcontroller.