element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Freedom development platform
  • Products
  • Dev Tools
  • Freedom development platform
  • More
  • Cancel
Freedom development platform
Blog Kinetis Design Studio 3.0 Kinetis SDK 1.3 Processor-Expert using FRDM-KL43Z: Part-2: Displaying Timer value on SLCD and Hyperterminal
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Freedom development platform to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: bheemarao
  • Date Created: 9 Dec 2015 12:45 PM Date Created
  • Views 423 views
  • Likes 1 like
  • Comments 0 comments
  • kds+kdsk1.3.0
  • frdm-kl43z
  • ksdk1.3.0
  • slcd
  • sdk
Related
Recommended

Kinetis Design Studio 3.0 Kinetis SDK 1.3 Processor-Expert using FRDM-KL43Z: Part-2: Displaying Timer value on SLCD and Hyperterminal

bheemarao
bheemarao
9 Dec 2015

This is in continuation to part-1 (for details click here), In this tutorial Here we are adding fsl_tpm and Debug UART to display the timer on Slcd and to hyperterminal.

 

Tutorial instructions to demonstrate the project


Create a new project as explained in part-1 and follow below instruction

We have added the below 4 components for our tutorial:

  • fsl_lcd
  • fsl_debug_console
  • fsl_tpm
  • fsl_gpio

 

For details about the fsl_lcd component please refer to my earlier blog (part-1 HERE)

 

fsl_debug_console details:

We are adding debug console in order to show/display the timer out value on hyperterminal. Configure the settings for debug console as shown below:

image

Its TX/RX is connected to PTA1/PTA2 pins and baud rate is configured to 115200 bps

 

fsl_tpm details:

We are adding TPM module and configured it as counter to give interrupt of every 1 second, its settings are as shown below:

image

image

The counter calculation is as shown below:


Clock source 8MHz

Prescaler is divide by 128

8MHz/128=62.5 kHz


So our counter final value must be: (for 1 sec delay)

One timer tick is 62.5kHz i.e 1/62.5kHz = 0.16 ms


For 1 sec (0.16ms)* X=1 sec

X = (1/0.16)*103

=62500

So the final counter value has to be 62500 to get 1 sec interrupt


fsl_gpio details:

We are connecting green LED to toggle for every one second interrupt we get, its configuration is as shown below:

image

We have to toggle the LED inside the timer/counter ISR, this is explained in coding section

We need to add the driver header file for slcd “s401m16kr.c” and “s401m16kr.h” inside the source folder:


These files can be found from location where you have installed KSDK 1.3.0 version

“C:\Freescale\KSDK_1.3.0\examples\frdmkl43zkl33z4\demo_apps\slcd_low_power_demo”

Import these files as shown.


Select the file location as mentioned and select the two files “s401m16kr.c” and “s401m16kr.h” in the check box as shown:

image

After adding these components we shall proceed to generate the corresponding code by clicking on the ‘generate code’ as shown below:

image

Insert the Code:


Now its time to add our code to execute the timer on slcd and hyperterminal.

We need to add a global flag in "Event.c" file to get an interrupt from a Timer/counter overflow as shown below:


int sec = 0,flag=0;

void tpmTmr1_IRQHandler(void)
{
  TPM_DRV_IRQHandler(tpmTmr1_IDX);
  /* Write your code here ... */
  //sec++;
  flag=1;
  GPIO_DRV_TogglePinOutput(LED1_GREEN);

}


We are toggling the Green LED inside the tpmTmr1_IRQHandler() isr routine and we are enabling the flag to 1.

i.e every time the counter overflows the interrupt occurs and the value of the flag is changed to 1

 

Add these lines of code inside main as shown below


int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization. ***/

  /* Write your code here */
  /* For example: for(;;) { } */

  extern int flag;

  // setting of Backplane connected to com0-com3
  SLCD_DRV_SetBackPlanePhase(display1_IDX, 59, kSLCDPhaseA);
  SLCD_DRV_SetBackPlanePhase(display1_IDX, 60, kSLCDPhaseB);
  SLCD_DRV_SetBackPlanePhase(display1_IDX, 14, kSLCDPhaseC);
  SLCD_DRV_SetBackPlanePhase(display1_IDX, 15, kSLCDPhaseD);

// starting the slcd function
  SLCD_DRV_Start(display1_IDX);


int min=0,secc=0 ;


debug_printf("%02d:%02d\r", min, secc);

for(;;){
             //SLCD_WritePin(44,0,1); // colon on
            SLCD_DispCol(1);

             if (flag == 1)
             {
              secc++;
              flag = 0;
              debug_printf("%02d:%02d\r", min, secc);
             }

             if ((secc%2) == 0)
             {
              //SLCD_WritePin(44,0,0); //colon off
                         SLCD_DispCol(0);
             }

             if (secc==60)
             {
              secc=0;
              min++;
             }

             if (min ==60)
              {
               min=0;
              }

            // SLCD_DispDot(1,1);

             SLCD_DispNum(3, secc%10);
             SLCD_DispNum(2, secc/10);
             SLCD_DispNum(1, min%10);
             SLCD_DispNum(0, min/10);

  }

  /*** 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 MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
  } 
/*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/


  We need to add the function SLCD_DispCol() in “s401m16kr.c” to glow the LCD segment for colon position which is located at pos(3,1) (com-3 segment-1)

 

void SLCD_DispCol(bool status)
{
    SLCD_WritePin(Pos2PinTable[3][1], 0, status);
}

image


Now compile and build the project by clicking the hammer button as shown below:

image

You can see the build result in console window as shown below:

image

Now we will execute our code by debug method:

image

Next select the PEMicro debugging interface and OpenSDA type as shown below:

image

After clicking on debug the system launches our project and below window appears.

image

You will see a Debug execution window, press Resume button as shown below:

image

You can see the timer value displaying on SLCD as shown below:

image

Output on hyperterminal can be seen by opening the application putty terminal as shown below:

image

image


Video output for the same can be seen below:

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

I have enclosed the project folder and executables for your quick reference.


Attachments:
SLCD Timer-KL43Z-srec.rar
SLCD Timer-KL43Z.rar
  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube