Renesas RZ/A1H Application Note
Renesas RZ/A1H Application Note

Renesas RZ/A1H Application Note

Tft backlight control using motor control pwm timer peripheral
Hide thumbs Also See for RZ/A1H:

Advertisement

Quick Links

APPLICATION NOTE
R30AN0230EG0100
RZ/A1H Group
Rev.1.00
TFT Backlight Control using Motor Control PWM Timer Peripheral
16 Oct 2015
Introduction
This application note describes how to use the Motor Control PWM Timer Peripheral of the RZ/A1H microcontroller to
provide a single variable duty-cycle PWM output. In this example, the PWM output is used to dynamically adjust the
brightness of a TFT Display attached to an RSK+RZ/A1H demonstration/development board. This application note is
supported by an embedded C project, developed in the e2 studio IDE.
Target Device
RZ/A1H
When applying the sample program covered in this application note to another microcontroller, modify the program
according to the specifications for the target microcomputer and conduct an extensive evaluation of the modified
program.
R30AN0230EG0100 Rev. 1.00
Page 1 of 22
16 Oct 2015

Advertisement

Table of Contents
loading

Summary of Contents for Renesas RZ/A1H

  • Page 1 16 Oct 2015 Introduction This application note describes how to use the Motor Control PWM Timer Peripheral of the RZ/A1H microcontroller to provide a single variable duty-cycle PWM output. In this example, the PWM output is used to dynamically adjust the brightness of a TFT Display attached to an RSK+RZ/A1H demonstration/development board.
  • Page 2: Table Of Contents

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral Contents Specification ........................3 Application Environment ....................4 Hardware ......................... 5 Hardware Scheme ........................5 RSK Configuration ........................5 3.2.1 Switches ..........................5 3.2.2 Jumpers ..........................6 3.2.3 Resistor modifications ......................6 Software ..........................
  • Page 3: Specification

    RV1 or by the switches SW1 – SW3 onboard the RSK. The application is set up to put the Renesas logo onto the display and a simple demonstration of the touch capabilities of the display.
  • Page 4: Application Environment

    C compiler KPIT GNUARM-NONE-EABI Toolchain v.14.02 Debugger Segger J-Link Board used RSK+RZ/A1H board and TFT display Table 3.1 Application Environment The peripherals used for the PWM backlight control and their function within the application are described in Table 2-1. Peripheral Function...
  • Page 5: Hardware

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral Hardware Hardware Scheme The PWM signal is generated by the MCU on port 3-1 (Pin AA7). This is routed to the backlight pin of the display, pin 34 of connector CN44, via an option link on the RSK. See section 3.2.3 for details of resistor link settings required for correct sample operation.
  • Page 6: Jumpers

    PWR_SEL 2-3 connected if power supplied from 5V, 1-2 connected if power supplied from 12V. Please refer to RSK+RZ/A1H User’s Manual section 2.1 for further information if required. It is essential that if a 12V supply is used that PWR_SEL is NOT linked on pins 2-3 or an overvoltage will be applied to the MCU and associated devices, resulting in likely destruction of the whole board 3.2.3...
  • Page 7: Software

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral Software User Operation of Sample Refer to the RSK Quickstart Guide (QSG) for instructions on how to import the project into the e studio workspace. The sample code can be built and loaded on the RZA1H in either HardwareDebug or Release mode. When the program is running, the panel records up to 5 discrete low pressure touches.
  • Page 8: Setting Cycle And Duty

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral 4.2.2 Setting Cycle and Duty The PWM output (PWB2B) is selected by setting OTS bit in PWDTR_2A register to 1. When compare match happens between PWCNT_2 (counter) and PWCYR_2 (period), the output pin PWM2B is set high, at the start of the cycle.
  • Page 9: Interrupts

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral Interrupts Table 4-3 lists interrupts used in the sample code. Interrupt Source (Interrupt ID) Priority Processing Overview CMI2 (165) Interrupt generated by PWCYR_2 compare match. Set the value of the next duty cycle in the PWBFR_2A register.
  • Page 10: List Of Constants/Error Codes

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral List of Constants/Error Codes Table 4-5 lists the constants used in the sample program and Table 4-6 lists the error codes. Constant Setting Description PWM_INT_PRIORITY1 PWM interrupt priority PWM_INT_PRIORITY2...
  • Page 11 RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral Constant Setting Description PWM_BUFFER_MASK 0x03FFu Mask the control and reserved bits of register PWBFR PWM_PERIOD_MASK 0x03FFu Mask for period register PWM_BTC1A_DISABLE 0x01u Disable data transfer from register PWBFR_1A PWM_BTC1C_DISABLE...
  • Page 12: List Of Structures/Unions

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral List of Structures/Unions /*== the kind of clock count ==*/ typedef enum clock_count CLOCK_COUNT_1, /* internal clock P0/1 CLOCK_COUNT_2, /* internal clock P0/2 CLOCK_COUNT_4, /* internal clock P0/4 CLOCK_COUNT_8,...
  • Page 13: R_Pwm_Initialise

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral 4.8.2 R_PWM_Initialise Synopsis Initialise Motor Control PWM Timer unit Header r_pwm_motor.h Source Location r_pwm_motor.c Declaration int32_t R_PWM_Initialise(const clock_count_t clock_count1, const clock_count_t clock_count2) Description This function initialises the Motor Control PWM timer as follows:...
  • Page 14: R_Pwm_Starttimer2

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral 4.8.5 R_PWM_StartTimer2 Synopsis Start PWM counter 2 Header r_pwm_motor.h Source Location r_pwm_motor.c Declaration void R_PWM_StartTimer (void) Description This function starts the PWM counter 2 Arguments none Return none 4.8.6...
  • Page 15: Pwm_Controller

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral 4.8.9 pwm_controller Synopsis Handles switch presses Header r_pwm_user.h Source Location r_pwm_user.c Declaration static void pwm_controller (void) Description Run from switch IRQ interrupts, this function toggles between switches and potentiometer to...
  • Page 16: Flowcharts

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral Flowcharts 4.9.1 Peripheral Initialisation Run from then main function, the function init_periph initializes the RIIC, switches, LEDs and the ADC. init_periph R_RIIC_RskInit R_SWITCHES_Init R_LED_Init R_ADC_Open Figure 4-2 Peripheral Initialisation Flow Chart R30AN0230EG0100 Rev.
  • Page 17: Main Processing

    RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral 4.9.2 Main Processing R_PWM_SampleMain() R_PWM_Initialise() R_PWM_SetPeriod2() R_PWM_SetDuty2A() Set switch callback function Set pwm compare-match callback function R_PWM_StartTimer2() while (1) R_GRAPHICS_GraphicsSampleUPD() Figure 4-3 Backlight Background Program Flow R30AN0230EG0100 Rev. 1.00...
  • Page 18: Reference Documents

    TFT Backlight Control using Motor Control PWM Timer Peripheral Reference Documents User's Manual: Hardware RZ/A1H Group User's Manual: Hardware Rev.1.00 R01UH0403EJ The latest version can be downloaded from the Renesas Electronics website. Application Notes: RZ/A1H Group I/O definition header file <iodefine.h> R01AN1860EJ RZ/A1H Group Example of Initialization (R01AN1864EJ)
  • Page 19 RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral Website and Support Renesas Electronics Website http://www.renesas.com/ Inquiries http://www.renesas.com/contact/ R30AN0230EG0100 Rev. 1.00 Page 19 of 22 16 Oct 2015...
  • Page 20 RZ/A1H Group TFT Backlight Control using Motor Control PWM Timer Peripheral Revision History Description Rev. Date Page Summary 1.00 16 Oct 2015 All trademarks and registered trademarks are the property of their respective owners. R30AN0230EG0100 Rev. 1.00 Page 20 of 22...
  • Page 21 General Precautions in the Handling of Microprocessing Unit and Microcontroller Unit Products The following usage notes are applicable to all Microprocessing unit and Microcontroller unit products from Renesas. For detailed usage notes on the products covered by this document, refer to the relevant sections of the document as well as any technical updates that have been issued for the products.
  • Page 22 10. It is the responsibility of the buyer or distributor of Renesas Electronics products, who distributes, disposes of, or otherwise places the product with a third party, to notify such third party in advance of the contents and conditions set forth in this document, Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics products.

Table of Contents