This tutorial will show step-by-step how to create a simple Processor Expert project that periodically toggles an output pin using a timer output without writing a single line of code.
The FRDM-KL25 board is used with one of the LEDs (blue) connected to the Timer/PWM Module 0 (TPM0), channel 1.
Timer Operation Description
The Timer/PWM Module 0 (TPM0) provides (besides other features) a counter with variable period (modulo), compare register an output pin suitable for the goal of periodic toggling.
The counter will be configured to continuously run in modulo range with a 300ms period, the output will be set when counter reaches the compare register value (150ms) and cleared when the counter resets.
The following picture describes the operation:
![14.png 14.png](/t5/image/serverpage/image-id/40673i4A7E63E2FDE646F2/image-size/large?v=v2&px=999)
Creating the Project
- First, create a new project with Processor Expert for KL25 configured as described in the tutorial Creating Processor Expert Project for FRDM-KL25
- Switch to Components Library view and its Categories tab and add the TimerUnit_LDD component from the category Logical Device Drivers / Timer by double-clicking on it or selecting pop-up menu command ‘Add to project’.
![10.png 10.png](/t5/image/serverpage/image-id/40676i30B8CE00E4DA511F/image-size/large?v=v2&px=999)
- The component appears in the Components view:
![11.png 11.png](/t5/image/serverpage/image-id/40647iBDE76584EB7929B0/image-size/large?v=v2&px=999)
- Use the Rename component command from the TU1’s context menu and change the name to BlueLED. :
![12.png 12.png](/t5/image/serverpage/image-id/40648iDDB151BFB2F9C651/image-size/large?v=v2&px=999)
- Double click the component to open it in the inspector and configure the properties according to the following picture:
![AAA.png AAA.png](/t5/image/serverpage/image-id/40672i906C64996105E92E/image-size/large?v=v2&px=999)
- Invoke code generation by clicking on the Generate Processor Expert Code button in the Components view of the project:
![BBB.png BBB.png](/t5/image/serverpage/image-id/40671iE48D387E8217E292/image-size/large?v=v2&px=999)
- The generated code is present in the Generated_Code folder of the project:
![15.png 15.png](/t5/image/serverpage/image-id/40652iED62FB65367EAFEB/image-size/large?v=v2&px=999)
Note: The generated code contains automatic initialization provided by Processor Expert configuring all needed registers, so it's not necessary to write any user code.
- Build the project using the Project / Build All.
- After the successful build, you can connect the FRDM-KL25 board and run the application by clicking the "Debug" icon and after the code gets loaded into the board the "Resume" button.
![ccc.png ccc.png](/t5/image/serverpage/image-id/40670iA7B0372B4C91CDF9/image-size/large?v=v2&px=999)
- The LED should start periodically blinking with blue color.