Lab Manual 4 Expts
Lab Manual 4 Expts
Lab Manual 4 Expts
EMBEDDED
LAB
MANUAL
2018
LABMANUAL TO HELP STUDENTS TO DO EXPERIMENTS ON FRDM Document
JUNE 2018
EMBEDDED LAB MANUAL 2018
KL25Z Microcontroller
The target microcontroller of the FRDM-KL25Z is the KL25Z128VLK4, a Kinetis L series
device in an 80 LQFP package. The KL25Z MCU features include:
32-bit ARM Cortex-M0+ core
- up to 48 MHz operation
- Single-cycle fast I/O access port
Memories
- 128 KB flash
- 16 KB SRAM
System integration
- Power management and mode controllers
- Low-leakage wakeup unit
- Bit manipulation engine for read-modify-write peripheral operations
- Direct memory access (DMA) controller
- Computer operating properly (COP) Watchdog timer
Clocks
- Clock generation module with FLL and PLL for system and CPU clock generation
- 4 MHz and 32 kHz internal reference clock
- System oscillator supporting external crystal or resonator
- Low-power 1kHz RC oscillator for RTC and COP watchdog
Analog peripherals
- 16-bit SAR ADC w/ DMA support
- 12-bit DAC w/ DMA support
- High speed comparator
Communication peripherals
- Two 8-bit Serial Peripheral Interfaces (SPI)
- USB dual-role controller with built-in FS/LS transceiver
- USB voltage regulator
- Two I2 C modules
- One low-power UART and two standard UART modules
Timers
- One 6-channel Timer/PWM module
- Two 2-channel Timer/PWM modules
- 2-channel Periodic Interrupt Timer (PIT)
- Real time clock (RTC)
- Low-power Timer (LPT)
- System tick timer
Human-Machine Interfaces (HMI)
- General purpose input/output controller
- Capacitive touch sense input interface hardware module
Clock Source
The Kinetis KL2 microcontrollers feature an on-chip oscillator compatible with three ranges
of input crystal or resonator frequencies: 32-40 kHz (low freq. mode), 3-8 MHz (high freq.
mode, low range) and 8-32 MHz (high freq. mode, high range). The KL25Z128 on the
FRDM-KL25Z is clocked from an 8 MHz crystal.
Input/Output Connectors
The KL25Z128VLK4 microcontroller is packaged in an 80-pin LQFP. Some pins are utilized
in on-board circuitry, but many are directly connected to one of four I/O headers. The pins on
the KL25Z microcontroller are named for their general purpose input/output port pin
function. For example, the 1st pin on Port A is referred to as PTA1. The I/O connector pin
names are given the same name as the KL25Z pin connected to it, where applicable.
DIODE CONFIGURATION
An RGB LED is actually three LEDs, red, green, and blue inside one package. LEDs need to
be turned on and off very fast for dimming (changing the voltage across it does not work like
it does in incandescent bulbs).The on and off times are so fast that human vision does not see
a flicker on the LED and only the average value is perceived. Three PWM output bits would
normally be used so that the brightness of each of the three LEDs can be controlled
independently. In the mbed APIs, three PWM Outs would be used to control the RGB LED.
A PWM value of 0.0 would be off and a 1.0 full on for each color LED. This allows a
program to vary both the color and brightness level of the LED. Typically an RGB LED has
four pins. One common pin and one for each of the three LEDs. In the LED seen below, the
common pin is the longest pin. If hardware PWM pins are not available, SoftPWM can
produce PWM signals on any pin by using software with timer interrupts.
Aim: To write a Program in Embedded C++ to blink the led for specific time period
Apparatus used:
FRDM KL25Z with Samtec FFSD IDC cable,
Hardware Interfacing Diagram:
ALGORITHM:
Step 1: Initialize the LED1 as digital out pin
Step 2: When the FRDM Board is powered high the while loop is tru and program stats
executing
Step 3: Make LED1 as high and call for a delay for 1 second
Step 4: Make LED2 as low and call for a delay for 1 second
Step 5: Make the program as infinite loop so that the LED blnks
PROGRAM
#include "mbed.h"
DigitalOut myled(LED1);
int main() {
while(1) {
myled = 1;
wait(1);
myled = 0;
wait(1);
}
}
CONCLUSION:
Thus a Embedded C++ program to blink an LED for a stipulated time was written and got
verified.
Program:
#include "mbed.h"
PwmOut led(LED1);
int main() {
while(1) {
for(float p = 0.0; p < 1.0; p += 0.1) {
led = p;
wait(0.2); }
for(float p = 1.0; p > 0.0 ; p -= 0.1) {
led = p;
wait(0.2); } } }
Note: Change the Led pin for different colour led to control its brightness
Conclusion: Thus the brightness of the LED was increased and decreased alternatively.
Aim: To drive different colours from a Tricolor LED using a different combination infinitely
Apparatus used:
FRDM KL25Z with Samtec FFSD IDC cable,
Hardware Interfacing Diagram:
COLOR TABLE:
LED1(Red) LED2 (Green) LED3 (Blue) Color obtained
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
DigitalOut rled(LED1);
DigitalOut gled(LED2);
DigitalOut bled(LED3);
int main() {
while(1) {
rled = 0;
gled = 0;
bled = 0;
wait(1);
rled = 0;
gled = 0;
bled = 1;
wait(1);
rled = 0;
gled = 1;
bled = 0;
wait(1);
rled = 0;
gled = 1;
bled = 1;
wait(1);
rled = 1;
gled = 0;
bled = 0;
wait(1);
rled = 1;
gled = 0;
bled = 1;
wait(1);
rled = 1;
gled = 1;
bled = 0;
wait(1);
rled = 1;
gled = 1;
bled = 1;
wait(1);
}
}