/******************************************************************************* * DISCLAIMER * This software is supplied by Renesas Electronics Corporation and is only * intended for use with Renesas products. No other uses are authorized. This * software is owned by Renesas Electronics Corporation and is protected under * all applicable laws, including copyright laws. * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * Renesas reserves the right, without notice, to make changes to this software * and to discontinue the availability of this software. By using this software, * you agree to the additional terms and conditions found by accessing the * following link: * http://www.renesas.com/disclaimer * (c) 2014 Renesas Electronics Corporation All rights reserved. *******************************************************************************/ /****************************************************************************** * File Name : r_taub.c * Version : 1.0 * Device(s) : R7F701007 RH850/F1L * Tool-Chain : IAR Embedded Workbench 1.30.1 * Description : This file is a sample of the TAUB. * Operation : - ******************************************************************************* ******************************************************************************* * History : DD.MM.YYYY Version Description * : 20.03.2014 1.00 First Release ******************************************************************************/ /****************************************************************************** Includes ******************************************************************************/ #include "r_typedefs.h" #include "iodefine.h" #ifdef __ghs__ #include "device.h" #endif #ifdef __IAR_SYSTEMS_ICC__ #include #endif /****************************************************************************** Imported global variables and functions (from other files) ******************************************************************************/ /****************************************************************************** Macro definitions ******************************************************************************/ //#define USE_TABLE_REFERENCE_METHOD /****************************************************************************** Exported global variables and functions (to be accessed by other files) ******************************************************************************/ void R_TAUB_Init( void ); void R_TAUB_Start( void ); /****************************************************************************** Private global variables and functions ******************************************************************************/ /****************************************************************************** * Function Name : void R_TAUB_Init( void ) * Description : This function initialize TAUB (ch.0). * Argument : none * Return Value : none ******************************************************************************/ void R_TAUB_Init( void ) { /* Set the interrupt flags */ MKTAUB0I0 = 1U; RFTAUB0I0 = 0U; #ifdef USE_TABLE_REFERENCE_METHOD TBTAUB0I0 = 1U; #else TBTAUB0I0 = 0U; #endif /* Specifies the CK3 , CK2 CK1 and CK0 clock TAUBnTPS - TAUBn Prescaler Clock Select Register b15:b12 TAUBnPRS3 - Specifies the CK3 clock - PCLK / 8 b11:b 8 TAUBnPRS2 - Specifies the CK2 clock - PCLK / 8 b 7:b 4 TAUBnPRS1 - Specifies the CK1 clock - PCLK / 8 b 3:b 0 TAUBnPRS0 - Specifies the CK0 clock - PCLK / 8 */ TAUB0.TPS = 0x3333U; /* PCLK(40MHz) / 8 -> 5MHz */ /* Data register for the capture/compare value TAUBnCDRm - TAUBn Channel Data Register b15:b 0 TAUBnCDR - 1ms */ TAUB0.CDR0 = 5000U - 1U; /* INTTAUBnIm cycle = count clock cycle * (TAUBnCDRm + 1) */ /* Controls channel m operation TAUBnCMORm - TAUBn Channel Mode OS Register b15:b14 TAUBnCKS - Selects the operation clock - Selected Operation CK0 b13 - Reserved set to 0 b12 TAUBnCCS0 - Selects the count clock for TAUBnCNTm counter - Must be set to 0 b11 TAUBnMAS - Specifies the channel as master or slave channel during synchronous channel operation - Must be set to 0 b10:b 8 TAUBnSTS - Selects the external start trigger - Must be set to 000'b b 7:b 6 TAUBnCOS - Specifies when the capture register TAUBnCDRm and the overflow flag TAUBnCSRm.TAUBnOVF of channel m are updated. - Must be set to 00'b b 5 - Reserved set to 0 b 4:b 1 TAUBnMD - Specifies the operation mode. For details, refer to the settings for individual functions. - Must be set to 000'b b 0 TAUBnMD0 - Specifies whether INTTAUBnIm is output at the beginning of count operation (when a start trigger is entered) or not. - INTTAUBnIm is not output */ TAUB0.CMOR0 = 0x0000U; /* Specifies the type of valid edge detection used for the TAUBTTINm input. TAUBnCMURm - TAUBn Channel Mode User Register b 7:b 2 - Reserved set to 0 b 1:b 0 TAUBnTIS - Specifies the valid edge of the TAUBTTINm input. - Must be set to 00'b */ TAUB0.CMUR0 = 0x00U; /* The simultaneous rewrite registers (TAUBnTOM, TAUBnTOC, TAUBnTOL, TAUBnTDE and TAUBnTDL) cannot be used with the Interval Timer Function. Therefore, these registers must be set to 0. */ TAUB0.TOM &= 0xFFFEU; TAUB0.TOC &= 0xFFFEU; TAUB0.TOL &= 0xFFFEU; TAUB0.TDE &= 0xFFFEU; TAUB0.TDL &= 0xFFFEU; /* Enables and disables independent channel output mode controlled by software. TAUBnTOE - TAUBn Channel Output Enable Register b15:b 0 TAUBnTOEm - Enables/disables independent channel output mode.- Disables independent channel 0 output mode. */ TAUB0.TOE &= 0xFFFEU; /* The simultaneous rewrite registers (TAUBnRDE, TAUBnRDS, TAUBnRDM, and TAUBnRDC) cannot be used with the Interval Timer Function. Therefore, these registers must be set to 0. */ TAUB0.RDE &= 0xFFFEU; TAUB0.RDS &= 0xFFFEU; TAUB0.RDM &= 0xFFFEU; TAUB0.RDC &= 0xFFFEU; MKTAUB0I0 = 0U; /* Enable INTTAUB0I0 interrupt */ } /****************************************************************************** * Function Name : void R_TAUB_Start( void ) * Description : This function starts TAUB (ch.0). * Argument : none * Return Value : none ******************************************************************************/ void R_TAUB_Start( void ) { /* Enables the counter for each channel TAUBnTS - TAUBn Channel Start Trigger Register b15:b 0 TAUBnTSm - Enables the counter for channel m. - Enables the ch.0 counter */ TAUB0.TS = 0x0001U; }