Beruflich Dokumente
Kultur Dokumente
August > 11
This tutorial brings you on getting working with 4-digit (4X8) segment LCD
present in KL46Z freedom board and demonstrate Time in Minutes and Seconds.
We will use the Freescales new Kinetis Design Studio Based on free, open-source
software including Eclipse, GNU Compiler Collection (GCC), GNU Debugger (GDB),
with an Eclipse Integrated Development Environment (IDE) for developing
embedded applications targeted at the range of Freescale Kinetis MCUs based on
ARM Cortex-M technology.
Download link:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?
code=KDS_IDE&fpsp=1&tab=Design_Tools_Tab
So lets start in creating a new project using KDS IDE
Open KDS IDE by double clicking the KDS icon present in your desktop:
It will ask for the Workspace, give the path of your choice and click ok
After opening you can see the KDS welcome window as shown here
Design Center Feedback
Now select the option Use Processor Expert for configuration and uncheck Use
Kinetis SDK for headers, drivers and click finish.
You can see the progress bar creating all required header files and libraries..Etc
After completion you can see below project window
Click on CPU, you can see the clock settings, i am using the default settings as
shown below i.e the clock source is from internal oscillator with reference clock of
32.768 KHz and Fast internal reference clock is 4 MHz as shown below.
Since now our project skeleton is ready (i.e no component module peripherals has
been added to our project), we need to add the required peripheral component
modules for our LCD Timer project.
LCD connection details
Refer to my earlier blog on
And the displays elements are illustrated below according to their references in
the connection table in the original data sheet:
In order to configure the SLCD driver to match this display 4 of its LCD pins are
configured as COM drive pins and 8 as segment drive pins. The COM drive pins
are configured to drive in different phases (eg. COM0 in phase 1, COM1 in phase
2, COM2 in phase 3 and COM3 in phase 4, where each of the phases are repeated
according to duty driving mode). The duty mode and any other specific
configuration are also set in the SLCD controller.
Now we need to add a LCD component available in Processor Expert to operate
the LCD screen embedded on the board.
FRDM-KL46Z is using a 4 digit display (LUMEX LCD-S401M16KR) 4x8 segments.
Following table shows connection from KL46 board to s401 LCD display and same
configuration need to be assigned to the port pins.
s401 pin Pin connection
1
(COM0)
(COM1)
LCD_P52
(COM3)
LCD_P18
3
5
6
7
8
9
10
11
12
(COM2)
(1D/1E/1G/1F)
(DP1/1C/1B/1A)
(2D/2E/2G/2F)
(DP2/2C/2B/2A)
(3D/3E/3G/3F)
(DP3/3C/3B/3A)
(4D/4E/4G/4F)
LCD_P19
LCD_P37
LCD_P17
LCD_P7
LCD_P8
LCD_P53
LCD_P38
LCD_P10
(COL/4C/4B/4A) LCD_P11
Components selection:
Select in the Components Library view the LCD module available in Component
Library > Logical Device Driver > Display > SegLCD_LDD and add it to project by double
clicking as shown below:
LCD component has Backplane pins and Frontplane pins, as there are 4 Backplane
pins, which are common pins connected to LCD com0, com1, com2, com3 pins.
Increase Backplane pins up to 4 by clicking on the +
Expand the Backplane pins menu by clicking on the white arrow and assign
corresponding port pins (refer to the KL46 LCD Pin table mentioned earlier) to the
Backplane pins:
Now similarly, define the 8 segment pins corresponding to the Frontplane pins in
KDS with following assignments:
Frontplane
Frontplane
Frontplane
Frontplane
Frontplane
pin0
pin1
pin2
pin3
pin4
/
/
/
/
/
Frontplane
Frontplane
Frontplane
Frontplane
Frontplane
pin
pin
pin
pin
pin
>
>
>
>
>
LCD_P37
LCD_P17
LCD_P7
LCD_P8
Design Center Feedback
LCD_P53
If you follow carefully the instructions above you should get a green tick on the
SegLCD1:SegLCD_LDD component in the Components view of your project.
Now as we are implementing Time in mins and secs we need a Periodic interrupt
for 1000ms, so select component TimerInt from CPU Internal Peripheral
section as shown below:
By clicking to
After this settings are made the component will be tick marked as correct symbol
as shown below:
Software drivers are required for communication between LCD controller and LCD
screen and manage the display. You can write your own driver or use Freescale
existing drivers.
To get the Freescale LCD drivers, simply download the Sample Code Package
KL46Z_sc.exe from the FRDM-KL46Z product page in the download tab.
www.freescale.com/FRDM-KL46Z
You will find a LCD folder following the path kinetis_kl46_sc_rev2\klxx-sc-
Copy these files and paste in the KDS Projects view in the Sources folder as
shown below:
Now our all the components and drivers are ready Next click on generate icon as
shown below:
You can see the tool generates required code as shown below:
All the required header files will get generated under Generated_Code
As we are using TimerInt component in interrupt mode to generate 1 sec
interrupt we need to define the action required in ISR() which is present in
Events.c file as shown below:
int second=0;
void TI1_OnInterrupt(void)
{
}
In ISR on every event trigger we are incrementing the second variable and we
are declaring this as global variable so that we can access this in our main
program.
Next open the main.c file available in the Sources folder from the KDS Project
view and write/paste the below lines of code:
#include"Cpu.h"
#include "Events.h"
#include "SegLCD1.h"
#include "TI1.h"
#include "TimerIntLdd1.h"
#include "TU1.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include "LCD.h"
DesignbyCenter
/* User includes (#include below this line is not maintained
Processor Feedback
Expert) */
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
***/
sprintf(lcdBuf,"%04i",secmin);
vfnLCD_Write_Msg(lcdBuf);
minute=minute+100;
if(minute>=10000){
minute=0;
second=0;
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T
RTOS component. */
#endif
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;){}
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
/* END main */
/*!
** @}
*/
/*
**
###################################################################
**
**
**
**
**
###################################################################
*/
sprintf(lcdBuf,"%04i",secmin);
vfnLCD_Write_Msg(lcdBuf);
minute=minute+100;
if(minute>=10000){
minute=0;
second=0;
I have created 3 main variables second, minute, and secmin to store the time
values seconds, minutes and the append value.
Based on timer interrupt set value (1seconds) the variable second will be
incremented every time when interrupt occurs and in the infinite for loop we are
checking if second is greater than or equalDesign
to 60 its
value is reset to 0
Center Feedback
The variable secmin is to meant add minute value and second value to display
together.
As minute is displayed in MSB 2-digits of LCD and it should get reset to 0 once it
crosses the value 10000
vfnLCD_Write_Msg((uint8 *)sLCDBuffer)
writes the character to digits of LCD this function is defined in LCD.c file in driver.
sprintf(sLCDBuffer,"%04i",i)
is writing the integer value i into char buffer sLCDBuffer array and %04i is
limiting the buffer value display to 4-digits
Example:
second
if second>=60,
second =0,
minute=minute+100
minute
59
60
30
22
60
43
25
60
59
0
0
00:00
00:02
155
500
600
900
930
1000
1022
5000
5060
9000
9043
9900
10000
100
100
9900
lcdbuf
59
100
0
secmin
55
if
minute>=10000,
minute=0,
second=0
9925
0000
0059
00:01
00:59
01:00
01:55
06:00
09:30
10:22
50:60
90:43
99:25
00:00
00:59
Make sure that the board is loaded with MSD-DEBUG-FRDMKL46Z48M_Pemicro_v114.SDA opensda driver file, if not follow below procedure:
Before launching the debug session, you need to setup your FRDM-KL46Z with the
OpenSDA P&E Debug interface.
To ensure a proper detection, download the P&E Windows USB drivers available at
www.pemicro.com/opensda and install it. At the same time download the P&E
Firmware Apps package.
Keep the Reset button while connecting the USB cable to SDA Connector (bottom
one below) to enter in Bootloader mode.
From your file explorer dragn drop or copy-paste in the BOOTLOADER drive the
configuration file MSD-DEBUG-FRDM-KL46Z48M_Pemicro_v114.SDA available in
the P&E Firmware Apps package.
Unplug and replug the USB cable
Windows should detect new peripherals (PEMicro OpenSDA Debug Driver, FRDMKL46Z Mass Storage drive, OpenSDA CDC Serial Port) and automaticaly install the
right drivers.
Debug configuration
Now we need to configure debug settings for the board.
To configure the board in KDS tool open Debug Configuration as shown below:
Now drop down the Interface field to select the exact USB debug port as shown
and select OpenSDA Embedded Debug-USB Port
In the port field you can see the OpenSDA driver gets detected if not able to see
this make sure you have connected the board to SDA usb port and click on
Refresh button.
Next select the Device name as shown below our target MCU is KL46Z256M4 and
select Apply and close.
Now the board is configured and detected in KDS and its ready for execution.
Build and Run the project
First save the project selecting File > Save All
Clean and Build the project by right clicking the project folder Timer in
secs_mins-KL46 as shown below:
Compile the project using Project > Build All or clicking on the icon
in the toolbar.
Design Center Feedback
available
Now enter the debug session by selecting Run > Debug Configuration. Click on
Timer in secs_mins-KL46 Debug and select Debug as shown below.
The debug window will open, click on the Resume button from the toolbar to
launch the debug session.
You can now watch the LCD Segment of your FRDM-KL46Z which displays minutes
and seconds as shown below
I have enclosed the project folder and video output execution for quick reference.
Timer in secs_mins-KL46.rar
170.7 K
2485 Views
2 Comments
Hi Cruz,
so in your programming logic you need to enable these segments for corresponding
DP values while writing to the buffer sprintf(sLCDBuffer,"%04i",i);
please refer to my blog:
http://www.element14.com/community/community/designcenter/kinetis_kl2_freedom_board/blog/
you can you the function: SymbolON(seg,com); to enable the DP segment and
SymbolOFF(seg[0],i); to disable the LCD segment.
Like (0)
Topics
3D Printing
Arduino
Business of
Engineering
Embedded
Industrial
Automation &
Robotics
Internet of
Things
Open Source
Hardware
Raspberry Pi
Projects
Get Started
With Pi
Sensors/MEMS
Single Board
Computers
Test and
Measurement
Wearable
Technology
Resources
Ask Industry
Experts
CadSoft EAGLE
Design
Code Exchange
Design
Challenges
Feedback &
Support
Learning Center
Legislation
Manufacturers
News
PCB Prototyping
Purchasing
Solutions
RoadTest
STEM Academy
Watch
element14 TV
Webinars and
Training
Content
Blog posts
Design
Center
Documents
Products
Polls
Boards
Discussions
Videos
Events
Analog Demo
Development
Compilers
OS &
Middleware
Members
Member
Directory
Member of the
Month
Ranking &
Points
Ask Industry
Experts
Top Members
Why Join?
This week on
element14
Test &
Store
EDA Tools
India
Simulation
Featured
Technologies
different store
Atmel Xplained
CircuitStudio
PCB Design
Freescale
Freedom
Platform
MATLAB for
Students
LPCXPRESSO
EcoSystem
Single Board
Computers
Follow Us
STM Discovery
Series
TI Launchpads
Timesys Linux
Support
Mobile App
Circuit Design
& Tools
Altium PCB
Design
EAGLE PCB
Design
PCB Fabrication
PCB Assembly
Design Services
Find
Technial Library
Where did
theknode go?
FAQs
Terms of Use
Privacy Policy
Sitemap