[go: up one dir, main page]

0% found this document useful (0 votes)
69 views6 pages

Lab Initialization, GPIO, Basic Scheduling

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 6

Embedded Systems Lab

Spring 2020

Lab # 1
Initialization, GPIO, Basic Scheduling

Please note: This is only a suggestion/proposal to help you put together the lab report,
the template/format can be changed per lab expectations. Please edit this document as
needed

Honor code:

Student Name::
School ID #
Submission Date:

Lab # 1
1. Experimental Objective:
The objective of this lab is to

 Understand General architecture & Key features of the EVB and the
microcontroller.

 Familiar with the Concepts of microcontroller pins (IOs) and usage Pins:

Digital inputs, (push buttons) and Digital Outputs (LEDs).

 First foot in the door exposure to the programming of I/O, which when executed
by the microcontroller (32-bit TM4C1294NCPDT) simply blinks LED located on
the development board.

2. Equipment required:
 32-bit TM4C1294NCPDT Microcontroller

3. Methodology/Design:
A microcontroller (MCU or μC) is a small integrated circuit device which is used to
control whole portion of electronic system. Micro-controller is a basic computer
system on a chip. They are used in many automatically controlled devices, such as
remote controls, power tools appliances, and toys. Microcontrollers electronically
controls many more processes by reducing the size, cost, power consumption and
cost as compared to other designs. A microcontroller is a single integrated circuit,
commonly with the following features:
• Central processing unit - The central processing unit functions like managing
data flow, arithmetic operations and generates control signals in accordance with the
sequence of instructions created by the programmer. It ranges from small and
simple 4-bit processors to 32- or 64-bit processors
• Input/output interfaces such as serial ports (UARTs)
• Other serial communications interfaces like I²C, Serial Peripheral Interface and
Controller Area Network for system interconnect
• Peripherals such as timers and watchdog
• RAM for data storage
• ROM, EPROM, EEPROM or Flash memory for program storage
• Clock generator - often an oscillator for a quartz timing crystal, resonator or RC
circuit

Input/output Ports
Microcontroller consists of one or more registers which are connected to the pins of
microcontroller. Usually, each I/O port is under control of another SFR, which means
that each bit of that register determines the state of the corresponding microcontroller
pin. To program a pin to be an output or an input, we simply send a 0 or a 1 to the
relevant bit in the TRISx register (0 for output and 1 for input) To make one of the output
pins high (+5v), we simply send a ‘1’ to the corresponding bit in PORTx register.

Flash memory
Memory of the microcontroller can be written and re-written many times the
microcontrollers with Flash ROM are ideal for learning, experimentation, and small-
scale manufacture. Because of its popularity, the most microcontrollers are
manufactured in flash versions today. So, if you are going to buy a microcontroller,
the type to look for is definitely flash.
Random Access Memory (RAM)
Random Access Memory is used for storing data and intermediate results during the
operation of the microcontroller temporarily. Once the power supply of the system
goes off, the contents of the memory become cleared.
Electrically Erasable Programmable ROM (EEPROM)
Like RAM, the contents of the EEPROM can be changed during the operation but
remains permanently saved even power is turned off. EEPROM usually used to
store values, during operation, which must be permanently saved. For example, if
you design an electronic lock or an alarm, it would be great to enable the user to
create and enter a password, but useless if it is lost every time the power supply
goes off. The ideal solution is the microcontroller with an embedded EEPROM.

4. Observation:
Structure of the Program
By using infinite toggling 28 bits loop of the address 0x2009C020, LED flashing code
is implemented after a certain delay. The shorter flowchart leads to smaller code size
and the longer flowchart translates to an inefficient code.
The overall structure of the program is shown in listing below which begins by
defining macros for the relevant register addresses. The main routine follows the
initialization steps described above then enters a loop in which it toggles an LED and
waits for some time.

#include” lm4f120h5q r.h”


int main (void) {//Enable peripherals. . . (1) . . .
// C o n fi g u r e pi n s. . . (2) . . .
while (1) {//Turn ON LED. . . (3) . . .//Delay for a bit. . . (4) . . .
//Turn OFF LED
. . . (5) . . .
}
}
Enabling the Clock
In the RUN mode RCGCPIO register provides capability to disable or enable the
GPIO module. In case when module is enabled, a module is provided a clock and
accesses to module registers are allowed. When disabled, the clock is disabled to
save power and accesses to module registers generate a bus fault. By asserting the
6th bit of RCGGPIO register the clock can be enabled for the GPIO port F. The
command can be used to enable clock signal for GPIO port F:
SYSCTL RCGCGPIO R = 0 x20 ; // ( 1 )

Configuring the Pin as Output


It is necessary to configure any required pins. In this case, a single pin (PF3) must
be configured as an output after enabling the clocks. To use the pin as a digital input
or output, the corresponding bit in the GPIODEN register must be set and then
setting a bit in the GPIODIR register configures the corresponding pin to be an
output. The commands used to set the corresponding bits in GPIODEN and
GPIODIR registers are given as follows:
GPIO PORTF DIR R = 0 x08; // (2)
GPIO PORTF DEN R = 0 x08;
Toggle the LED
LED can be turned ON and OFF by setting and resetting the corresponding bits in
the GPIODATA register. The commands for toggling LED are as follows
GPIO PORTF DATA R = 0 x08; // (3)
GPIO PORTF DATA R = 0 x00; // (5)
Introducing a Delay
We cannot observe the toggling of LED because of very high frequency. We
introduce a delay loop in order to observe the toggle sequence of the LED.
int counter = 0 ;
while (counter < 20000){ // ( 4 )
++counter ;
}

5. Conclusion:
By completing this experiment, we have sufficient knowledge about architecture & Key
features of the EVB and the microcontroller. In this lab we explored different
components of (32-bit TM4C1294NCPDT) microcontroller which simply blinks LED
located on the development board

Space FilerSpace Filler


*****

You might also like