Arduino/C3/Mixing-Assembly-and-C-programming/English-timed

From Script | Spoken-Tutorial
Revision as of 17:32, 26 October 2018 by Sandhya.np14 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time Narration
00:01 Welcome to the Spoken Tutorial on Mixing Assembly and C programming.
00:07 In this tutorial, we will learn to:

write a function in Assembly routine to perform initialization,

call that Assembly routine in AVR-GCC program to blink the Dot LED of the Seven Segment display.

00:24 To follow this tutorial, you should have basic knowledge of :

electronics,

AVR-GCC and

Assembly Programming.

00:37 To record this tutorial, I am using:

Arduino UNO Board and Ubuntu Linux operating system version 14.04.

00:50 We also require some external devices such as:

Breadboard,

Seven-Segment Display,

01:00 220 ohm Resistor,

Arduino UNO Board and

Jumper Wires.

01:09 The Dot pin of the Seven Segment Display is connected to the pin 13 of the Arduino.
01:16 Any one of the common pins is connected to the +5 Volts through a resistor.
01:23 This is the live setup of the connection.
01:28 Now, we will write an Assembly routine to perform the initialization.
01:34 Open any text editor and type the following.
01:38 This assembly routine program initializes and sets pin 13 of Arduino as output.
01:45 Let me explain the code line by line.

This line sets the Special Function Register offset to zero.

01:54 These two lines make this assembly routine globally accessible.

It enables other programs to use it.

02:03 Here, init is the subroutine name.

These two lines set pin 13 of Arduino as output.

02:13 Save the code as initasm.S in capital in the Downloads folder.

Since this is the subroutine, it is saved as .S extension.

02:27 All codes used in this tutorial are available in the Code Files link of this tutorial.

You can download and use it.

02:37 Now, we will write an AVR-GCC program to call this subroutine and blink the Dot LED.
02:45 Open any text editor and type the following.
02:49 This code will blink the Dot LED continuously.
02:54 The first line,"init()" calls the Assembly subroutine. These lines of code alternatively turn the Dot LED ON and OFF causing it to blink.
03:08 Save the code as blink.c in the Downloads folder.
03:13 Download the Makefile from the code files link of this tutorial.

Place it in the same folder where blink.c file is saved.

03:24 I’ll open the Makefile in text editor.
03:28 Note that this Makefile is different from the one previously used.
03:34 In the Makefile, ensure that “TARGET = blink” and ASRC = “initasm.S”.
03:44 Here, “blink” is the main program and “initasm” is the subroutine.
03:50 You need to change the filename and subroutine name if you have given a different name.

Then save the Makefile.

03:59 Switch to the terminal.
04:02 Go to the folder where blink.c file is saved.

Type: make space FNAME in capital =blink and press Enter.

04:17 Now, you can see that the Dot LED is blinking.
04:22 This brings us to the end of this tutorial. Let us summarize.
04:28 In this tutorial, we learnt to:

write a function in Assembly routine to perform initialization and

call that Assembly routine in AVR-GCC program to blink the Dot LED.

04:43 As an assignment-

Change the above program to increase the delay.

Observe the delay in the blinking of the Dot LED

04:53 The video at the following link summarizes the Spoken Tutorial project. Please download and watch it.
05:01 The Spoken Tutorial Project team:

conducts workshops and gives certificates. For more details, please write to us.

05:11 Please post your timed queries in this forum.
05:15 Spoken Tutorial project is funded by NMEICT, MHRD, Government of India. More information on this mission is available at this link.
05:26 This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay. This is Priya from IIT Bombay. Thanks for watching.

Contributors and Content Editors

Pratik kamble, Sandhya.np14