AVR MCU as per Industrial Approach: Session 12

[justify]In the last session 11 we initiated writing a bare-metal code for blinky and explored various things such as MCU architecture, Pin map, Data Direction Registers (DDR), Register Value/Data formatting in Binary, Hexadecimal and Decimal.[/justify]
[justify]We also roughly talked about Bit Addressing and Byte Addressing.[/justify]

[justify]Today we will continue the Kick-Start Session to complete writing the bare-metal blinky code for AVR 8-bit (ATMEGA328) MCU without using Arduino libraries and in built functions. We will explore how to access an individual bit by writing to the complete byte address and also explore running patterns on multiple LEDs.[/justify]

[center]atmega328[/center]

To join the Session: Link

27 Jan, 2021 | 4:00 pm to 6:00 pm | Wednesday

1 Like

In this Session we did the followings,

  • We explored PORTx Register.

  • We wrote bare metal C code and also Arduino code for blinky.

  • We compare the code size of both bare metal C code and Arduino Sketch (Code).

  • We discussed the OR and Shift operation on Register (Byte) value to set the particular bit.

Below are some snaps of the sessions:

Screenshot from 2021-01-27 18-28-40

Screenshot from 2021-01-27 18-28-54

Screenshot from 2021-01-27 18-29-06

One of interesting thing we discover here is the code size or how much memory does the bare metal C code will consume as compared to Arduino Code for the same blinky program.

Here are two code compiled in the same Arduino IDE:

Bare Metal C code

Arduino Sketch (Code)