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.
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.
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...
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.
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...
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.
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.
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.
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...
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,...
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:...
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...
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...
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.
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...
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.
Need help?
Do you have a question about the RZ/A1H and is the answer not in the manual?
Questions and answers