Embedded programming


This week assignment is to do the following tasks:

  • Read ATtiny Data sheet
  • Program your Echo Hello world board to blink, with as many different programming languages and programming environments as possible.
  • Experiment with other architectures (optionally).

Step1:Know more about Microcontrollers

I have a previous knowledge with Microcontrollers as I used PIC microcontroller in many projects but I never used AVR microcontroller, so I wanted to recap first some important concepts. (This is just a quick recap of all the links listed down).

  1. Microprocessor Vs Microcontroller
  2. Microprocessor Microcontroller
    MPU MCU
    An integrated circuit used for general purpose computing tasks. An integrated circuit used for specific applications only
    Usually used in computers Usually used in embedded systems and Engineering projects
    Must be connected to external peripherals to work. ( like memory ) It doesn’t need any external peripherals to work. ( it has memory inside)
    It has ALU ( Arithmetic Logic Unit) , I/O ports and Registers It has CPU (Central processing unit), RAM / ROM, programmable I/O ports, serial port, timer, And all required components

    In simplest term,
    MPU = CPU
    MCU = MPU + Peripherals + Memory
    Peripherals = Ports + Clock + Timers + UART/USART + ADC + DAC + LCD Drivers + Other Stuffs
    Memory = Flash + SRAM + EPROM + EEPROM


    Useful links to understand more:
    - http://maxembedded.com/2011/06/mcu-vs-mpu/
    - https://circuitdigest.com/article/what-is-the-difference-between-microprocessor-and-microcontroller


  3. Microcontroller families
  4. There are many Microcontrollers families like 8051, PIC, AVR, ARM to name just a few. These families are different from each other in the processor architecture, Number of registers which means the amount of numbers that can be stored, Speed of execution, number of instructions, peripherals and off course the manufacturer. Each family contains number of microcontrollers which differ from each other in number of ports, number of clocks, amount of memory… So in any project we have to choose the family and then which controller in this family to use.


    Useful links:
    - https://ti.tuwien.ac.at/ecs/teaching/courses/mclu/theory-material/Microcontroller.pdf
    - https://www.engineersgarage.com/tutorials/getting-started-with-microcontrollers


  5. AVR microcontroller
  6. The family that we will work with is the AVR family manufactured by Atmel. Its architecture is based on RISC, 8 and 32 bits registers. It has high computing performance with better power efficiency according to Atmel website.


  7. How to program a MCU
  8. You choose an IDE (Integrated Development Environment) which you can install on your computer and write the code on it using a programming language. The IDE work as a compiler, it will extract the machine language from your code. After that the code will be uploaded to the MCU using a circuit connected to both your computer and your MCU.


    Useful links:
    - http://www.build-electronic-circuits.com/microcontroller-programming/


    Step2: Read ATtiny Datasheet

    I started scrolling down in the datasheet through the things that I thought I need to know which are the function of each pin and what I can do with this microcontroller

    1. The pins
      • In any data sheet there is always a part which tells the function of each pin
      • Pin NUmber Name Main Function
        1 VCC Supply voltage
        14 GND The ground
        2,3,4,5 Port B = PB0-PB3 I/O port consists of 4 pins = 4 bit port
        6,7,8,9,10,11,12,13 PORTA= PA0-PA7 I/O port consists of 8 pins = 8 bit port

        These are the main functions but each pin can be used in other functions

      • Port B can read and send digital Data only but port A has the option of read and send both analog and digital data.
      • Every pin must be configured before using to be input or output.

    2. Peripherals
    3. The ATtiny has:

      • 2 PWM channels ( Pulse Width Modulation )
      • 8 channels 10 bit ADC ( Analog to Digital Converter)
      • 32 general purpose working registers
      • 8 bit timer/counter

      There are all the details that anyone needs to know about ATtiny in the data sheet so I thought it’s better to check it again when I need any information and I will update it here .


      Step3: Programming Hello Echo board

      (In our fab lab we face a problem of broken milling tool so I didn’t got the chance to make the board so I will update this part after the arrival of the new milling tool)


    That's all :)