Docsity

Microprocessors Lab: Learning C Programming and PIO Interfacing (Fall 2007), Lab Reports of Microprocessors

Toggle sidebar
bg1
Page 1 of 1
E 332L Microprocessors Lab (Fall 2007)
– Lab 4 (Week 6)–
Objective: In this lab, you will learn C programming language and the use of C for interfacing to buttons,
switches, and LEDs.
Note 1: Use Lab 4’s sof and ptf files.
Note 2: KEY0 is processor’s reset. KEY1 (called button1 in Nios II) is level-sensitive button. KEY2 is rising-edge
sensitive button. KEY3 is rising-edge with interrupt button.
Note 3: Create a Hello World C/C++ Nios II Application project, compile this project to obtain the system.h.
system.h is in your_project_name_syslib
debug
system_description
system.h. Then, add your sources
to the project. Remember, you can’t have more than one main in a project!
Part 1: Learn C Programming Language by Examples
Debug (Use Debug As
Nios II Instruction Set Simulator) the following source files. Document your
understanding of the given source files by commenting everything. You will/might need references in this page:
http://coen.boisestate.edu/smloo/ece332fall2007/tutorial.htm. In the debugger, use “Step Into” and/or “Step Over”.
Observe the assembly code in the Disassembly window and memory usage in the Memory Monitor.
Example of a commented line:
typedef unsigned char byte; // make our own data types
Question: There is a main in our source code. Why is there an alt_main in debug session?
The sources files you need to comment are:
a. types.c
b. suspect.c
c. main.c, sub1.h, sub1.c, sub2.h, and sub2.c.
Part 2: PIO Interfacing using C
This segment of code use pointer to read from switches and display the read value to red (led_switches.c).
Assignment: You need to convert the value from the switches to BCD and display this value to seven-segment
LEDs.

Partial preview of the text

Download Microprocessors Lab: Learning C Programming and PIO Interfacing (Fall 2007) and more Lab Reports Microprocessors in PDF only on Docsity!

Page 1 of 1

E 332L Microprocessors Lab (Fall 2007)

– Lab 4 (Week 6)–

Objective: In this lab, you will learn C programming language and the use of C for interfacing to buttons,

switches, and LEDs.

Note 1: Use Lab 4’s sof and ptf files.

Note 2: KEY0 is processor’s reset. KEY1 (called button1 in Nios II) is level-sensitive button. KEY2 is rising-edge sensitive button. KEY3 is rising-edge with interrupt button.

Note 3: Create a Hello World C/C++ Nios II Application project, compile this project to obtain the system.h. system.h is in your_project_name_syslib  debug  system_description  system.h. Then, add your sources to the project. Remember, you can’t have more than one main in a project!

Part 1: Learn C Programming Language by Examples

Debug ( Use Debug As  Nios II Instruction Set Simulator ) the following source files. Document your understanding of the given source files by commenting everything. You will/might need references in this page: http://coen.boisestate.edu/smloo/ece332fall2007/tutorial.htm. In the debugger, use “ Step Into ” and/or “ Step Over ”. Observe the assembly code in the Disassembly window and memory usage in the Memory Monitor.

Example of a commented line:

typedef unsigned char byte; // make our own data types

Question: There is a main in our source code. Why is there an alt_main in debug session?

The sources files you need to comment are: a. types.c b. suspect.c c. main.c, sub1.h, sub1.c, sub2.h, and sub2.c.

Part 2: PIO Interfacing using C

This segment of code use pointer to read from switches and display the read value to red (led_switches.c).

Assignment: You need to convert the value from the switches to BCD and display this value to seven-segment LEDs.