Embedded Programming Group Assignment ATTiny44 "Arduino" ATTiny44 "C" ATTiny1614 "Arduino" ATTiny1614 "C" Raspberry Pi Pico Individual Assignment ATTiny44 "Arduino" ATTiny44 "C" ATTiny1614 "Arduino" ATTiny1614 "C" Downloads

Embedded Programming


Assignment requirements:

Group Assignment
  • Compare the performance and development workflows for different microcontroller families.
  • Document your work (in a group or individually).
Individual Assignment
  • Read the datasheet for the microcontroller you are programming.
  • Design an MCU board using Attiny1614 (Add the essential circuit - Add pin header for GPIOs - Add a switch and LED).
  • Program the board to BLINK when the button is pressed using C and Arduino C.

Learning outcomes:

  • Identify relevant information in a microcontroller datasheet.
  • Implement programming protocols.

Assessment criteria

  • Linked to the group assignment page.
  • Documented what you learned from reading a microcontroller datasheet.
  • Programmed your board.
  • Described the programming process/es you used.
  • Included your source code.
  • Included a short 'hero video' of your board.

Group Assignment

In this week we will learn more about programming and how the board can be effected when using different programming languages.
So we program our ATTiny44 and ATTiny1614 using Arduino code and C code.

ATTiny44 "Arduino"

  • We programmed the ATTiny44 to blink the led with no delay to measure the frequency of the blinking with oscilloscope.
  • When programming using Arduino liberary we got a frequency of 185KHz.


  • ATTiny44 "C"

  • This time we used a C code.
  • When programming using C we got a frequency of 2.4MHz.


  • ATTiny1614 "Arduino"

  • We programmed the ATTiny1614 to blink the led with no delay to measure the frequency of the blinking with oscilloscope.
  • When programming using Arduino liberary we got a frequency of 756KHz.


  • ATTiny1614 "C"

  • This time we used a C code.
  • When programming using C we got a frequency of 2.8MHz.


  • Previous results was a prove for the concept that controlling the chip registers directly consumes less memory and takes less instructions to do the job.

  • Raspberry Pi Pico

  • This time we used Python code.
  • We got a frequency of 57KHz.



  • Individual Assignment


    ATTiny44 "Arduino"

  • I Started by my ATTiny44 to make it blink when I press the button.
  • I used Arduino IDE and used my FabISP programmer to upload the code.
  • I checked the pinout and pin mapping compatible with Arduino to use it in my code.
  • Go to electronics production week if you want to know more about code uploading steps.



  • Code:

  •                       #define LED 2
                          #define SW 3
      
      
                          void setup() {
                            // put your setup code here, to run once:
                            pinMode(LED, OUTPUT);   // Set Pin 2 to output
                            pinMode(SW, INPUT_PULLUP);   // Set Pin 3 to input & activate pull-up at Pin 3
                              // set clock divider to /1
                            //
                            CLKPR = (1 << CLKPCE);
                            CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);
                            }
      
                          void loop() {
                            // When pressing push button blink the led.
                            if(digitalRead (SW) == 0){
                              digitalWrite(LED, 1);
                              delay(250);
                              digitalWrite(LED, 0);
                              delay(250);
                            }
                          }
                          

    ATTiny44 "C"

  • This time I used a C code.
  • To learn more about how to control registers of the chip I read the I/O Ports section in the datasheet.
  • I copied the makefile from class schedule and edited it to my file name.
  • Then programmed with terminal in programming steps.
  • Opened the folder where I put the make file and the .c file code and then right click and Git Bash here.
  • make -f ed.blink.c.make then > make -f led.blink.c.make program-usbtiny-fuses then > make -f led.blink.c.make program-usbtiny
  • Go to electronics production week if you want to know more about code uploading steps.


  • Code:

  •                         #include 
                            #include 
    
                            int main()
                            {
    
                                DDRA |= (1<<DDA2);   // Set Pin A2 to output
                                DDRA &= ~(1<<DDA3);  // Set Pin A3 to input
                                PORTA |= (1<<DDA3);   // activate pull-up at Pin A3
                                  
                                // set clock divider to /1
                                CLKPR = (1 << CLKPCE);
                                CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);
    
                                while(1){
                                    if(!(PINA &  (1<<PA3)))
                                    {
                                        PORTA |= (1<<PA2);
                                        _delay_ms(250);
                                        PORTA &= ~(1<<PA2);
                                        _delay_ms(250);
                                    }
                                }
                            }
                            

    ATTiny1614 "Arduino"

  • I designed an ATTiny1614 based PCB and added a switch and LED to it.
  • I used Arduino IDE and my UPDI programmer to upload the code.
  • I checked the pinout and pin mapping compatible with Arduino to use it in my code.
  • Go to electronics production week if you want to know more about code uploading steps.



  • Code:

  •                             #define LED 0
                                #define SW 1
                                
                                
                                void setup() {
                                  // put your setup code here, to run once:
                                  pinMode(LED, OUTPUT);   // Set Pin 2 to output
                                  pinMode(SW, INPUT_PULLUP);   // Set Pin 3 to input & activate pull-up at Pin 3
                                
                                  }
                                
                                void loop() {
                                  // When pressing push button blink the led.
                                  if(digitalRead (SW) == 0){
                                    digitalWrite(LED, 1);
                                    delay(250);
                                    digitalWrite(LED, 0);
                                    delay(250);
                                  }
                                }
                                


    ATTiny1614 "C"

  • This time I used a C code.
  • To learn more about how to control registers of the chip I read the PORT - I/O Pin Configuration section of the datasheet, also, I have looked at some previous students documentations to learn more.
  • I used Arduino IDE (Wrote a C code in Arduino IDE) and my UPDI programmer to upload the code.
  • Go to electronics production week if you want to know more about code uploading steps.


  • Code:

  •  
    
                                    #include 
                                    #include 
    
                                    int main()
                                    {
    
                                      PORTA.DIR |= (1 << 4); // Set Pin A4 to output
                                      PORTA.DIR &= ~(1 << 5); // Set Pin A5 to input
                                      PORTA.PIN5CTRL = (1 << 3); // activate pull-up at Pin A5
    
                                      //PORTA.OUT &= ~(1 << 4); // Set the initial state of the LED OFF
    
    
    
                                        while(1){
                                        if (!(PORTA.IN & (1 << 5)))
                                        {
                                        PORTA.OUT |= (1 << 4);
                                        _delay_ms(50);
                                        PORTA.OUT &= ~(1 << 4);
                                        _delay_ms(50);
                                        }
                                        }
                                    }
                                  



    Downloads

    ATTiny1614 PCB design, gerber files and png for traces and outline