Skip to content

Commit

Permalink
added example for port toggling in stop / snooze mode using DTC on RL…
Browse files Browse the repository at this point in the history
…78G14
  • Loading branch information
GiPa committed Mar 5, 2013
1 parent d80d87b commit dea700b
Show file tree
Hide file tree
Showing 27 changed files with 7,384 additions and 0 deletions.
18 changes: 18 additions & 0 deletions G14/gpio_toggle_snooze_mode/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
This example project uses the RJ timer to trigger DTC transfers in background.

The system is driven in stop mode, and uses the 15KHz oscillator (FSUB).

By default the LED on the RL78 promo board (connected on P7.7) should toggle with a frequency of about 2 sec.

Port 7 is being written in background with an alternating pattern of 0xFF and 0x0

The timer RJ event is processed by the DTC to:

- configure the next RJ timer match
- write on the P7 data port

After this event, the system goes back to stop mode.

The maximum time interval between measurements is linked to the 15KHz clock and the 16-bit range of the RJ counter, so about 4,3 seconds max.

The demo has been tested on the RL78G14RPB board (USB-stick form factor promotion board)
237 changes: 237 additions & 0 deletions G14/gpio_toggle_snooze_mode/applilet3_src/md_lnkr5f104le.xcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@

///******************************************************************************
//* 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
//*
//* Copyright (C) 2011, 2012 Renesas Electronics Corporation. All rights reserved.
//******************************************************************************/

///*
//*******************************************************************************
//* File Name : md_lnkr5f104le.xcl
//* Version : Applilet3 for RL78/G14 V1.01.03.06 [10 Sep 2012]
//* Device(s) : R5F104LE
//* Tool-Chain : IAR Systems iccrl78
//* Description : This is the IAR link file.
//* Creation Date: 01.03.2013
//*******************************************************************************
//*/
//-------------------------------------------------------------------------
// XLINK command file template for RL78 microcontroller R5F104LE.
//
// This filecan be used to link object files from the RL78
// Assembler, ARL78, and the C/C++ compiler ICCRL78.
//
// This file is generated from the device file:
// DR5F104LE.DVF
// Copyright(C) 2011 Renesas
// Format version V3.00, File version E1.00f
//-------------------------------------------------------------------------

//-------------------------------------------------------------------------
// The following segments are defined in this template link file:
//
// INTVEC -- Interrupt vectors.
// CLTVEC -- Calltable vectors.
// RCODE -- Code used by C/C++ startup and run-time library.
// CODE -- Code used by __near_func, __interrupt and __callt functions.
// XCODE -- Code used by __far_func functions.
// NEAR_CONST_ -- Constants used by __near const.
// FAR_CONST -- Constants used by __far const.
// SADDR_x -- Variables used by __saddr.
// NEAR_x -- Variables used by __near.
// FAR_x -- Variables used by __far.
// NEAR_HEAP -- The heap used by near data model.
// FAR_HEAP -- The heap used by far data model.
// SWITCH -- Switch tables used by near code model.
// FSWITCH -- Switch tables used by near far model.
// DIFUNCT -- Dynamic initialization vector used by C++
//
// Where _x could be one of:
//
// _Z -- Initialized data (initvalue = 0 or without init value).
// _I -- Initialized data (initvalue != 0).
// _ID -- The initial values of _I.
// _N -- Uninitialized data, used by __no_init.
//-------------------------------------------------------------------------

//-------------------------------------------------------------------------
// Define CPU
//-------------------------------------------------------------------------

-cRL78

//-------------------------------------------------------------------------
// Size of the stack.
// Remove comment and modify number if used from command line.
//-------------------------------------------------------------------------

//-D_CSTACK_SIZE=80

//-------------------------------------------------------------------------
// Near constant location.
// 0 -> Mirrored in rom area 0x00000 - 0x0FFFF
// 1 -> Mirrored in rom area 0x10000 - 0x1FFFF
// 2 -> Writeable constants
// Remove comments and modify number if used from command line.
//-------------------------------------------------------------------------

//-D_NEAR_CONST_LOCATION=0
//-D_NEAR_CONST_LOCATION_START=02000
//-D_NEAR_CONST_LOCATION_END=0E8FF

//-------------------------------------------------------------------------
// Size of the heaps.
// Remove comment and modify number if used from command line.
//-------------------------------------------------------------------------

//-D_NEAR_HEAP_SIZE=400
//-D_FAR_HEAP_SIZE=4000

//-------------------------------------------------------------------------
// Define the format functions used by printf/scanf.
// Default is full formatting.
// Remove appropriate comment(s) to get reduced formatting
// if used from command line.
//-------------------------------------------------------------------------

//-e_PrintfTiny=_Printf
//-e_PrintfSmall=_Printf
//-e_PrintfLarge=_Printf

//-e_ScanfSmall=_Scanf
//-e_ScanfLarge=_Scanf

//-------------------------------------------------------------------------
// Define if row buffering should be used by terminal output.
// Default is no buffering.
// Remove comment to get buffered terminal output if used from command line.
//-------------------------------------------------------------------------

//-e__write_buffered=__write

//-------------------------------------------------------------------------
// Allocate the read only segments that are mapped to ROM.
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Interrupt vector segment.
//-------------------------------------------------------------------------
-Z(CODE)INTVEC=00000-0007F

//-------------------------------------------------------------------------
// CALLT vector segment.
//-------------------------------------------------------------------------
-Z(CODE)CLTVEC=00080-000BD

//-------------------------------------------------------------------------
// OPTION BYTES segment.
//-------------------------------------------------------------------------
-Z(CODE)OPTBYTE=000C0-000C3

//-------------------------------------------------------------------------
// SECURITY_ID segment.
//-------------------------------------------------------------------------
-Z(CODE)SECUID=000C4-000CD

//-------------------------------------------------------------------------
// Reserved ROM areas for OCD Firmware: 000CE-000D7
// 0FF00-0FFFF
//-------------------------------------------------------------------------
-Z(CODE)OCNIROM1=000CE-000D7
-Z(CODE)OCNIROM2=0FF00-0FFFF

//-------------------------------------------------------------------------
// Far data segments.
//-------------------------------------------------------------------------
-Z(CONST)FAR_ID#0FBFF
-Z(DATA)FAR_I=FE900-FFE1F

//-------------------------------------------------------------------------
// Startup, Runtime-library, Near, Interrupt
// and CALLT functions code segment.
//-------------------------------------------------------------------------
-Z(CODE)RCODE,CODE=000D8-0FBFF

//-------------------------------------------------------------------------
// Data initializer segments.
//-------------------------------------------------------------------------
-Z(CONST)NEAR_ID=[000D8-0FBFF]/10000
-Z(CONST)SADDR_ID=[000D8-0FBFF]/10000
-Z(CONST)DIFUNCT=[000D8-0FBFF]/10000

//-------------------------------------------------------------------------
// Constant segments
//-------------------------------------------------------------------------
-Z(CONST)NEAR_CONST=_NEAR_CONST_LOCATION_START-_NEAR_CONST_LOCATION_END
-Z(CONST)SWITCH=000D8-0FBFF
-P(CONST)FAR_CONST,FSWITCH=[000D8-0FBFF]/10000

//-------------------------------------------------------------------------
// Far functions code segment.
//-------------------------------------------------------------------------
-P(CODE)XCODE=[000D8-0FBFF]/10000

//-------------------------------------------------------------------------
// Allocate the read/write segments that are mapped to RAM.
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// EEPROM segment.
// Note: This segment will not be automatically created
// and it will not be initialised by CSTARTUP!
//-------------------------------------------------------------------------
-Z(DATA)EEPROM=F1000-F1FFF

//-------------------------------------------------------------------------
// Short address data and workseg segments.
//-------------------------------------------------------------------------
-Z(DATA)WRKSEG=FFE20-FFEDF
-Z(DATA)SADDR_I,SADDR_Z,SADDR_N=FFE20-FFEDF

//-------------------------------------------------------------------------
// Near data segments.
//-------------------------------------------------------------------------
-Z(DATA)NEAR_I,NEAR_Z,NEAR_N=FE900-FFE1F

//-------------------------------------------------------------------------
// Far data segments.
//-------------------------------------------------------------------------
-Z(DATA)FAR_Z=[FE900-FFE1F]/10000
-P(DATA)FAR_N=[FE900-FFE1F]/10000

//-------------------------------------------------------------------------
// Heap segments.
//-------------------------------------------------------------------------
-Z(DATA)NEAR_HEAP+_NEAR_HEAP_SIZE=FE900-FFE1F
-Z(DATA)FAR_HEAP+_FAR_HEAP_SIZE=[FE900-FFE1F]/10000

//-------------------------------------------------------------------------
// Stack segment.
//-------------------------------------------------------------------------
-Z(DATA)CSTACK+_CSTACK_SIZE=FE900-FFE1F

//-------------------------------------------------------------------------
// Select the output file format if used from command line.
// Remove comment to select the file format if used from command line.
//-------------------------------------------------------------------------
//-Fdebug

//-------------------------------------------------------------------------
// End of File
//-------------------------------------------------------------------------
72 changes: 72 additions & 0 deletions G14/gpio_toggle_snooze_mode/applilet3_src/r_cg_cgc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/***********************************************************************************************************************
* 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
*
* Copyright (C) 2011, 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/

/***********************************************************************************************************************
* File Name : r_cg_cgc.c
* Version : Applilet3 for RL78/G14 V1.01.03.06 [10 Sep 2012]
* Device(s) : R5F104LE
* Tool-Chain : IAR Systems iccrl78
* Description : This file implements device driver for CGC module.
* Creation Date: 01.03.2013
***********************************************************************************************************************/

/***********************************************************************************************************************
Includes
***********************************************************************************************************************/
#include "r_cg_macrodriver.h"
#include "r_cg_cgc.h"
/* Start user code for include. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
#include "r_cg_userdefine.h"

/***********************************************************************************************************************
Global variables and functions
***********************************************************************************************************************/
/* Start user code for global. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */

/***********************************************************************************************************************
* Function Name: R_CGC_Create
* Description : This function initializes the clock generator.
* Arguments : None
* Return Value : None
***********************************************************************************************************************/
void R_CGC_Create(void)
{
/* Set fMX */
CMC = _00_CGC_HISYS_PORT | _00_CGC_SUB_PORT | _00_CGC_SYSOSC_DEFAULT | _00_CGC_SUBMODE_DEFAULT;
MSTOP = 1U;
/* Set fMAIN */
MCM0 = 0U;
/* Set fSUB */
XTSTOP = 1U;
OSMC = _10_CGC_RTC_CLK_FIL;
/* Set fCLK */
CSS = 0U;
/* Set fIH */
HIOSTOP = 0U;
}

/* Start user code for adding. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */
Loading

0 comments on commit dea700b

Please sign in to comment.