[Top] Renesas R7F0Cxxx series microcontroller CS+ for CC introductory tutorial (1)

Copyright statement: This article is an original article by the blogger, please declare when reprinting

The author of this article is yjydyod, reproduced from: https://blog.csdn.net/yjydyod


foreword

        This is an introductory tutorial about Renesas R7F0Cxxx series microcontrollers. There is very little information about this on the Internet, which may be the reason why fewer people use it. Due to work reasons, I have been in contact with this microcontroller during this time, so I wrote this blog, hoping to give you some help.

        R7F0Cxxx is mainly for a series sold in mainland China and Hong Kong, it mainly includes the following products:

   

This series of device files are not integrated in the IDE of the official website, so the device files must be imported manually before building the project. At the same time, the plug-in that automatically generates peripheral module drivers that comes with the IDE cannot be used, and the independent software AP4 is used instead. Below I will use an example to show how to start the first R7F0Cxxx microcontroller program.

Start

        This application example shows how to start the first R7F0Cxxx MCU program by controlling the flashing of LED lights with R7F0C014B microcontroller.

1 specification

        This application note describes the application of using a timer array unit to control the flickering of LED lights . For related peripheral functions and uses, please refer to "Table 1.1 ".

Table 1.1 Related peripheral functions and uses

Peripheral function use
Timer Array Unit 0 Channel 0 0.5s timer for updating led status
P70

LED light control

2 Development Conditions

        The reference routines in this application note need to be executed under the following conditions.

Table 2.1 Development Conditions
project content
Microcontroller used R7F0C014B
Integrated Development Environment CS+ for CA CX V4.01.00 或者 CS+ for CC V6.01.00
Peripheral circuit driver generation program AP4 for RL78_EC V1.05.00
Emulator   EZ-CUBE
Microcontroller Device File r7f0c014_dif.zip

2.1 Microcontroller

        The minimum system board of R7F0C014B is selected, as shown in Figure 2.1.1 below:
        Figure 2.1.1 Minimum System Board
    
        The wiring method of LED is shown in Figure 2.1.2:
Figure 2.1.2 LED wiring diagram

2.2 Integrated Development Environment

        Renesas has two integrated development environments, CS+ for CACX (hereinafter referred to as CA) and CS+ for CC (hereinafter referred to as CC). The difference between them is that CA will eventually be phased out. Now the CA version is 4.0, while the CC version is 6.0.

       The feedback from the supplier's technical support is that CA was developed by NEC in the early days , and NEC 's IP is doing well, while Renesas' peripherals are doing well, and then combining the strengths of the two, Renesas did a good job About the RL78 series of microcontrollers. However , the compilation efficiency of the CA compiler is not very good, and then Renesas directly developed a new compiler to replace the CA compiler, which is the latter CC .

        CA has higher support and richer resources. The demos on the official website are all based on CA, but I suggest that you use CC as an IDE later. The usage of CC is basically the same as that of CA, and the compiled binary files are compiled from CA. is 20% smaller, and CC can support long long type variables, while CA only supports long type variables.  

        I will not talk about the IDE environment download and installation here. As for the usage method, I will focus on CC V6.01, and some differences in CA configuration will also be mentioned.

2.3 Peripheral circuit driver generation program

        AP4 is a standalone software tool that automatically generates peripheral module drivers based on user settings. A compilation tool (compiler) can be selected. AP4 generates suitable peripheral module control programs for the compilation tool, and also generates workspace files and project files for the integrated development environment. AP4 for RL78_EC supports MCU products for China - R7F0Cxx series, and supports CA78K0R and CC-RL compilers. Other microcontrollers can be generated with IDE.

2.4 Emulator

        EZ-CUBE is an on-chip debug emulator with flash memory programming function, which can be used to debug programs or program programs into built-in flash memory microcontrollers. The emulator can be purchased from agents or Taobao, and the fare is about 200 yuan. If you need information, you can search EZ-CUBE on the official website, and all the information can be downloaded.

2.5 Microcontroller Device Files

        Since the R7F0Cxxx series are dedicated chips for China, the device files are not integrated in the integrated development environment and must be imported manually. Download path (take R7F0C014 as an example):

        Renesas Official Website->Products->MCU Products for China->R7F0C014->Software and Tools->Tools->Screening. As shown below:


3 Build the project

3.1 Import device file

        Unzip the downloaded R7F014MCU device file:

        Open the Readme.txt file:


Here's how different versions of the IDE import device files. Take me as an example, I installed CS+ for CC V6.01, so I need to copy all the files in Device_Custom to C:\Program Files (x86)\Renesas Electronics\CS+\CC\Device_Custom\RL78 path, and then When adding other types of chip device files, just overwrite it. It should be noted here: "When installing for the first time, there is no Device_Custom\RL78 path in the CC folder, so you need to create it manually".

3.2 创建工程

         打开CS+ for CC软件,在[Create New Project]板块点击[GO]按钮。

   

        按照下图所示配置设置后,点击[创建]。

        

3.3 代码生成

        在本节中,您将配置您要使用的微控制器中内置的外设功能。 使用代码生成工具,只需执行GUI操作即可自动生成程序。

3.3.1 创建AP4工程

        打开AP4软件,点击New Project。

        

按照下图所示配置设置后,点击[创建]。


注意,这里的项目名称和存放位置与创建的工程一样,这是为了方便项目管理。

3.3.2 系统设置

        在这一步中,您可以配置系统的功能,例如设置时钟或选择是否使用片上调试功能。

        双击时钟发生器,打开系统版面。

            

        选择[Pin assignment]选项卡并单击[Fix settings]按钮。

       

        选择[On-chip debugging setting]选项卡并配置,如下所示。

        

3.3.3 管脚设置

        双击Port Function,打开管脚版面。选择[Port7]标签,并作如下设置。

        

        在这一步中,您决定使用哪一个引脚。参阅图2.1.2,P7的Bit 0作为输出脚,且默认输出为1。

3.3.4 定时器设置

        双击[Timer Array Unit],打开定时器版面,选择[General Setting]标签,并且选择Channel 0为[Interval timer]

        

        选择[Channel 0]标签并按如下设置。

        

3.3.5 看门狗定时器设置

        双击[Watchdog Timer],并进行如下设置。

        

3.3.6 代码生成

        当设置完成后,还需要选择编译器,CS+ for CC选择CCRL,CS+ for CA CX选择CA78K0R,最后点击[Generate code]进行代码生成。如下图:

        

3.4 编码

 3.4.1 添加自动生成的代码

          从AP4软件切回CC软件,右键File->Add->Add New Category创建[code generate]文件夹,如下图。

        

        

        右键code generate->Add->Add File

        

        在弹出的的对话框中,选择建立工程的文件夹,将cg_src中的所有文件添加

        

        结果如下:

        

        然后把原有的hdwinit.asm、stkinit.asm和main.c移除,结果如下:

        

        到此,就可以开始编程了。     

3.4.2 编辑  

        双击r_main.c, 在下面添加定时器0通道0启动函数R_TAU0_Channel0_Start().

        

        双击r_cg_tau_user.c,对程序做如下修改

          

3.4.3 编译项目

        点击保存->点击[Rebuild Project]标签,显示结果如下:

        

        显示Error0个,警告Warning 4个,其中两个软件有效期警告不管,另外两个出现的原因刚好是下载到调试器需要配置的信息,这将在下一章讲解。

4 调试

4.1 连接到调试器并下载

4.1.1 选择调试工具

         右键【Debug Tool]->[Using Debug Tool]->[RL78 EZ Emulator].              

        

        选择了RL78 EZ Emulator作为调试工具

        

4.1.2 设置调试器使用区域与程序使用区域

        这一步很重要,假如不做设置的话,编译时就出现上面描述过的两个警告,而在下载程序时会出现E1203124 或 E0204001错误。

        CC按下图进行设置:

        

        其中Option byte values for OCD与User option byte value 这两个值可以从AP4生产的文件r_option_cc.txt的如下两项获取。

        

        再一次编译后发现,除了软件有效期警告外其他的两个警告消失了。

        CA按下图进行设置

        

        对应的值可以在AP4生成的r_option_ca.txt中找到,

        

4.1.3 连接EZ

        按要求与EZ调试器连接。

4.1.4 下载module file 到EZ

        点击【Download】下载。

自此可以开始你的瑞萨单片机之旅了,其他调试方法以后有时间完善。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324732655&siteId=291194637