/********************************************************************************************************************** * 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) 2020 Renesas Electronics Corporation. All rights reserved. *********************************************************************************************************************/ /***********************************************************************/ /* */ /* FILE :Main.c or Main.cpp */ /* DATE :Tue, Oct 31, 2006 */ /* DESCRIPTION :Main Program */ /* CPU TYPE : */ /* */ /* NOTE:THIS IS A TYPICAL EXAMPLE. */ /* */ /***********************************************************************/ //#include "typedefine.h" #include "r_smc_entry.h" volatile int g_dmac4_flag; //0:DMAC未使用, 1:DMAC使用中 volatile int g_sci1_txi_flag; //0:TX送信中or送信準備ができていない, 1:送信準備完了(TXI割り込み要求を掛けて問題ない) int sci_dmac_out(uint8_t * tx_buf, uint16_t tx_num); //SCI送信関数 #ifdef __cplusplus //#include // Remove the comment when you use ios //_SINT ios_base::Init::init_cnt; // Remove the comment when you use ios #endif void main(void); #ifdef __cplusplus extern "C" { void abort(void); } #endif void main(void) { volatile unsigned long x; unsigned char *msg[6]; R_Config_SCI1_Start(); g_sci1_txi_flag = 1; //TXI要求準備OK R_Config_DMAC4_Start(); DMAC4.DMCNT.BIT.DTE = 0U; g_dmac4_flag = 0; /* Set TXD1 pin */ PORT2.PMR.BYTE |= 0x40U; msg[0]= "SCI DMAC test 1\r\n"; msg[1]= "SCI DMAC test 2\r\n"; msg[2]= "SCI DMAC test 3\r\n"; msg[3]= "SCI DMAC test 4\r\n"; msg[4]= "SCI DMAC test 5\r\n"; msg[5]= "SCI DMAC test 6\r\n"; while(sci_dmac_out(msg[0], 17) != 0); //1回目 while(sci_dmac_out(msg[1], 17) != 0); //2回目(送信完了前にDMACの転送が間に合うタイミング) while(sci_dmac_out(msg[2], 17) != 0); //3回目(送信完了前にDMACの転送が間に合うタイミング) for (x=0; x<10000000; x++) __nop(); //長時間ウェイト while(sci_dmac_out(msg[3], 17) != 0); //4回目(送信完了前にDMACの転送が間に合わないタイミング) for (x=0; x<10000000; x++) __nop(); //長時間ウェイト while(sci_dmac_out(msg[4], 17) != 0); //5回目 while(sci_dmac_out(msg[5], 17) != 0); //6回目 while(1) { __nop(); } } #ifdef __cplusplus void abort(void) { } #endif int sci_dmac_out(uint8_t * tx_buf, uint16_t tx_num) { //SCI送信関数 //戻り値 //0: 正常終了 //1: DMAC使用中 if (g_dmac4_flag == 1) return 1; //転送アドレスと転送回数セット DMAC4.DMCRA = tx_num; DMAC4.DMSAR = (void *)tx_buf; //DMAC起動 g_dmac4_flag = 1; DMAC4.DMCNT.BIT.DTE = 1; if (g_sci1_txi_flag == 1) { //送信の準備ができている場合はTXI割り込み要求(DMAC起動トリガ)を掛ける SCI1.SCR.BYTE |= 0xA0U; g_sci1_txi_flag = 0; } return 0; }