Embedded programming

Assignment - Embedded programming

  • I -- group assignment:
  • - compare the performance and development workflows for other architectures
  • II -- individual assignment:
  • read a microcontroller data sheet program your board to do something, with as many different programming languages and programming environments as possible

Individual assignment:

To solve this weekly task, I chose ATtiny85 because I made a PCB board with it in the previous task.

ATtiny85 Features / Technical Specifications:
- High performance design - Low power consumption in operating mode on 1.8 volts current consumption is only 300uA & on power down mode current consumption is only 0.1uA on 1.8V.
- Total number of Analog Input pins are 6
- Contains 8 kilobytes of flash memory
- Contains 512 bytes of SRAM
- Contains 512 bytes of EEPROM
- 32 Registers
- Minimum & maximum temperature -40 degree centigrade to 105 degree centigrade
- Advance RISC
- Lock program functionality for programming code security
- Contains total two 8-bit timers or counters one with compare mode and other is high speed.
- Total number of I/O pins are 6
- Universal Serial interface on pin 5,6 and 7.
- Contains USI (Universal Serial Interface)
- 4channels 10 bit ADC
- Watchdog programmable Timer
- Minimum and maximum operating voltage from 1.8V DC to 5.5V DC

Pin Configuration:
PIN 1 - PB5 -PCINT5, ADC0, dW, RESET - Pin 1 is a reset pin, analog pin, ADC input, bootloader reprogram and remove
PIN 2 - PB3 also GPIO3 - XTAL1, CLKI, ADC3, OC1B, PCINT3 -Pin3 is for USB programming, analog input, XTAL input, PWM
PIN 3 - PB4 also GPIO4 - XTAL2, CLKO, ADC2, OC1B, PCINT4 - Pin4 is for USB programming, analog input, XTAL output, PWM
PIN 4 - GND - Ground - Ground / Negative Supply of the system
PIN 5 - PB0 also GPIO0 - MOSI, AIN0, OC0A, OC1A, DI, SDA, AREF, PCINT0 - The Pin 5 performs as PWM ouput, SPI communication, 12C communication
PIN 6 - PB1 also GPIO1 - MISO, AIN1, OC0B, OC1A, DO, PCINT1 - Pin 6 can be used for SPI data output, PWM output
PIN 7 - PB2 also GPIO2 - SCK, ADC1, T0, SCL,PCINT2 - Pin 7 is for analog input, SCK for SPI data & SCL
PIN 8 - VCC - Positive Voltage - Positive supply of the system.

The ATtiny25/45/85 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the ATtiny25/45/85 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption versus processing speed.

The resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers. The ATtiny25/45/85 provides the following features: 2/4/8K bytes of In-System Programmable Flash, 128/256/512 bytes EEPROM, 128/256/256 bytes SRAM, 6 general purpose I/O lines, 32 general purpose working registers, one 8-bit Timer/Counter with compare modes, one 8-bit high speed Timer/Counter, Universal Serial Interface, Internal and External Interrupts, a 4-channel, 10-bit ADC, a programmable Watchdog Timer with internal Oscillator, and three software selectable power saving modes.

Block diagram of the AVR Architecture.
In order to maximize performance and parallelism, the AVR uses a Harvard architecture – with separate memories and buses for program and data. Instructions in the Program memory are executed with a single level pipelining. While one instruction is being executed, the next instruction is pre-fetched from the Program memory. This concept enables instructions to be executed in every clock cycle. The Program memory is In-System Reprogrammable Flash memory.

I first chose to use the Arduino Uno as a programmer. For this I sought help on the next page programming-attiny85-with-arduino-uno .

File-> preferences -> https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

I installed the ATtiny board.

Now it’s time to connect my PCB with arduino through ISP header. SPI communication on ATTiny85 is part of Universal Serial Interface (USI). USI offers Synchronous data transfer and more about USI that can be found in datasheet. I have to set up the Arduino Uno as a programmer. I loaded the ArduinoISP sketch. Now he is a programmer and I can program ATTiny85.

Then I go to compile and upload and it works. I tried three different sketches, blink led and push button led.

Video blink:

Next IDE to try is Microchip Studio . Microchip Studio is an Integrated Development Environment (IDE) for developing and debugging AVR® and SAM microcontroller applications. It merges all of the great features and functionality of Atmel Studio into Microchip’s well-supported portfolio of development tools to give you a seamless and easy-to-use environment for writing, building and debugging your applications written in C / C ++ or assembly code.

When I opened Microchip studio I go to file-> new project. I chose AVR XC8 C Application Project.

From the device selection I chose tiny85. I wrote a simple code by writing to I/O registers decribed before in datasheet. I needed to import a delay library.

Than I go to build solution, there were no errors. To upoad it I used avrdude.

I installed the avrdude.

Group assignment:

For the group assignment we had to compare the performance and development workflows for other architects. I did this task together with a colleague using microbit.
Microbit
The Micro Bit is an open source hardware ARM-based embedded system designed by the BBC for use in computer education in the United Kingdom. The device is described as half the size of a credit card and has an ARM Cortex-M0 processor, accelerometer and magnetometer sensors, Bluetooth and USB connectivity, a display consisting of 25 LEDs, two programmable buttons, and can be powered by either USB or an external battery pack. The device inputs and outputs are through five ring connectors that form part of a larger 25-pin edge connector.

Microbit can be programmed in several ways, code blocks, Python and JavaScript. I went to (https://makecode.microbit.org/) and chose javascript.

I made a flashing hearth. There is a simulator on the page with which we can test the written code. To download a hex code we go to download button.

Then we copy the hex code directly to the microbit. The result .....

Microbit