
p. 1
ECE 331 Preparation Exercise 8 Solutions
Please refer to Modules 6-7 course notes to answer the following questions.
1. What does GPIO stand for?
general purpose input / output, which defines a digital I/O pin whose value (0 or 1) can
be read or written, in contrast to pins with specific analog, serial, etc. functional
attributes.
2. List the peripheral modules (hardware functions), besides GPIO, on the Kinetis MKL25Z128VLK4
microcontroller.
Serial communication blocks: USB, UART (3), SPI (2), I2C (2)
Timer blocks: Timer/PWM (3), Periodic interrupt timer, Low-power timer, Real time clock
Analog blocks: Analog-to-digital converter, Digital-to-analog converter, Analog
comparator
3. Briefly describe what it means to say peripheral registers are “memory mapped”.
All peripheral function/configuration registers have a unique address in the controller
memory space. This allows those registers to be read/written using standard
instruction, just like reading/writing normal memory.
4. Each peripheral module can be routed to pins on multiple ports. What controls the routing of peripheral
functions to specific pins? In other words, how is the function of a pin set?
Each pin can be assigned to one of eight “alternate” functions using the 3-bit MUX field
of each pin’s PORTx_PCRn register.
5. Pin Control Registers (PCR) contains several fields to configure pin features. List and briefly describe the
fields/features discussed in class. Note some were covered during lecture for Module 6 and others for
Module 7.
Each PORTx_PCRn register has fields for: Interrupt status flag, Interrupt
configuration, Pin alt-function (MUX) control.
Other useful functions not discussed in ECE331 include: Drive strength enable, Pull
up/down enable, and Pull up/down select.
6. What is the base address for each of the following GPIO configuration registers? Note: you do not need to
remember these addresses for the exam, but you should know where to find them in the course notes and
understand how GPIO configuration is distributed over various registers.
a) Port B PCR
b) Port D GPIO (DDR, DOR, etc.)
c) Port C Clock Gate
a) Base address of Port B PCR is PORTB_PCR0 = 0x4004.A000
b) PORTD_GPIO base = 0x400F.F0C0
c) All port clock gates are in SIM_SCGC5 = 0x4004.8038
7. Each GPIO port has a “maskable” clock, meaning it can be enabled or disabled (gated). Are the clocks to
each GPIO port enabled or disabled by default (at reset)?
The reset value on bits 5:0 of regiseter SIM_SCGC5 are 0, thus all clocks are disabled
by default.