This section describes how to use the debug console for standard I/O.
To perform some operation using a program's internal standard library functions, such as the scanf function for reading the data entered from the keyboard or the printf function for outputting data, use the Debug Console panel shown below.
For details about each functionality of the debug console, see the section in which the Debug Console panel is described.
Before standard I/O based on the Debug Console panel can be used in a C/C++ program, there must be a low-level interface routine in the program.
CS+ comes with sample project "RX610_Tutorial_DebugConsole" for the E1/E20, which has the following files for debug console functions.
Each called by the internal initialization routine "PowerON_Reset_PC" of the initialization routine file resetprg.c.
Called by low-level interface routines "write" and "read," respectively.
[E1] [E20] [EZ Emulator] |
[Simulator] |
To use sample projects with debug console functions, follow the procedure described below.
From [Open Sample Project] on the Start panel of CS+, load sample project "RX610_Tutorial_DebugConsole" for the E1/E20.
To execute stream I/O in simulator mode, you need to edit the content of a file (lowlvl.src) for low-level interface routines (assembly language part) to make it usable for a simulator.
Replace the contents of "lowlvl.src" with the following sample code for the simulator.
To select or switch the debug tool, use the context menu shown by right clicking on the [Microcontroller type Debug tool name (Debug Tool)] node on the Project Tree panel.
For the details of debug tool selection, see "2.3.1 Select the debug tool to use". |
When the simulator is to be used, the following settings must be made in the [Stream I/O] [Simulator] category on the [Debug Tool Settings] tab of the Property panel.
To use files for the same low-level interface routines (assembly language part) as the emulator, specify [Emulator mode]. (By default, [Simulator mode] is specified.)
This property is displayed only when [Simulator mode] is specified in the [Select stream I/O mode] property.
If you intend to perform standard I/O or file I/O, select [Yes] (default selection: [No]).
This property is displayed only when [Simulator mode] is specified in the [Select stream I/O mode] property.
If you have replaced the low-level interface routines (assembly-language part) with the sample code for the simulator, enter "0" (default).
Choose [Build & Download] from the [Debug] menu on the Main window. Then, when connected with the debug tool, perform a build and a download (see "2.5.1 Execute downloading").
Open the Debug Console panel.
Execute the program (see "2.9 Execute Programs").
By executing the program, perform data I/O on the Debug Console panel.
This program reads 10 entries of data that have been entered from the keyboard onto the panel by the scanf function and then sorts the input data in ascending order. It then outputs data onto the panel using the printf function.
The element names of the array "a" in which data is stored are output onto the panel by the printf function in the main function. |
When data is entered from the keyboard onto the panel, the data is read in by the scanf function in the main function. |
If you disable the local echo back function in [Echo Back] selected from the Debug Console panel's context menu, the character strings you have entered will not be displayed (local echo back will not be performed.) |