/******************************************************************************* * 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_taud_InputPulseInterval.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 input pulse interval (TAUD). * 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 ******************************************************************************/ /****************************************************************************** Exported global variables and functions (to be accessed by other files) ******************************************************************************/ void R_TAUD_Init( void ); void R_TAUD_Start( void ); /****************************************************************************** Private global variables and functions ******************************************************************************/ /****************************************************************************** * Function Name : void R_TAUD_Init( void ) * Description : This function initializes the TAUD ch.7. (Input capture function) * Argument : none * Return Value : none ******************************************************************************/ void R_TAUD_Init( void ) { /* TAUD0.7 port settings */ /* TAUD0I7(P10_3):CN2A-23pin */ PFCAE10 &= 0xFFF7U; PFCE10 &= 0xFFF7U; PFC10 &= 0xFFF7U; PM10 |= 0x0008U; PMC10 |= 0x0008U; DNFATAUD0ICTL = 0x00U; DNFATAUD0IEN |= 0x0080U; /* Set interrupt flags */ MKTAUD0I7 = 1U; RFTAUD0I7 = 0U; TBTAUD0I7 = 0U; /* Specifies the CK3 , CK2 , CK1 and CK0 clock TAUDnTPS - TAUDn Prescaler Clock Select Register b15:b12 TAUDnPRS3 - Specifies CK3_PRE clock - PCLK / 1 b11:b 8 TAUDnPRS2 - Specifies CK2_PRE clock - PCLK / 1 b 7:b 4 TAUDnPRS1 - Specifies CK1_PRE clock - PCLK / 1 b 3:b 0 TAUDnPRS0 - Specifies CK0_PRE clock - PCLK / 16 */ TAUD0.TPS = 0x0004U; /* PCLK(80MHz) / 16 */ /* Controls master channel operation TAUDnCMORm - TAUDn Channel Mode OS Register b15:b14 TAUDnCKS - Selects an operation clock. - Selected Operation CK0 b13:b12 TAUDnCCS0 - Selects a count clock for TAUDnCNTm counter. - Set to 00'b b11 TAUDnMAS - Specifies whether the channel is a master channe or slave channel during synchronous channel operation. - Set to 0'b b10:b 8 TAUDnSTS - Selects an external start trigger. - Valid edge of TAUJTTINm input signal, which is specified by TAUJnCMURm.TAUJnTIS[1:0]. Set to 001'b b 7:b 6 TAUDnCOS - Specifies the timing for updating capture register TAUDnCDRm and overflow flag TAUDnCSRm.TAUDnOVF of channel m. - Updated (cleared or set) when valid edge of TAUJTTINm input is detected. Set to 01'b b 5 - Reserved set to 0 b 4:b 1 TAUDnMD - Specifies an operating mode. - Capture mode. Set to 0010'b b 0 TAUDnMD0 - Specifies whether INTTAUDnIm is generated at the beginning of count operation (when a start trigger is entered) or not. - INTTAUJnIm is not generated when operation starts. Set to 0'b */ TAUD0.CMOR7 = 0x0144U; /* Specifies the type of valid edge detection used for the TAUDTTINm input. TAUDnCMURm - TAUDn Channel Mode User Register b 7:b 2 - Reserved set to 0 b 1:b 0 TAUDnTIS - Specifies a valid edge of TAUDTTINm input signal. - Rising and falling edge detection. Set to 10'b. */ TAUD0.CMUR7 = 0x02U; /* Disable the channel output mode. TAUDnTOE - TAUDn Channel Output Enable Register b15:b 0 TAUDnTOEm - Enables/disables the independent channel output function. - Disables the independent timer output function (controlled by software). */ TAUD0.TOE &= 0xFF7FU; /* The simultaneous rewrite registers (TAUDnRDE, TAUDnRDS, TAUDnRDM, and TAUDnRDC) cannot be used with the Interval Timer Function. Therefore, these registers must be set to 0. */ TAUD0.RDE &= 0xFF7FU; TAUD0.RDS &= 0xFF7FU; TAUD0.RDM &= 0xFF7FU; TAUD0.RDC &= 0xFF7FU; MKTAUD0I7 = 0U; /* Enable INTTAUD0I7 interrupt */ } /****************************************************************************** * Function Name : void R_TAUD_Start( void ) * Description : This function start the TAUD (ch.7). * Argument : none * Return Value : none ******************************************************************************/ void R_TAUD_Start( void ) { /* Enables the counter for each channel TAUDnTS - TAUDn Channel Start Trigger Register b15:b 0 TAUDnTSm - Enables the counter operation of channel m. - Enables the ch.7 counter */ TAUD0.TS = 0x0080U; }