Renesas provides a code generator called Applilet (“Application Leading Tool”) for the RL78 family and others as well.
瑞薩為RL78系列以及其他芯片提供了一款代碼生成器叫做Applilet(“Application Leading Tool”)去枷。
A valuable feature of Applilet is that it provides “round-trip engineering” in that you can generate code with Applilet, add in your own code, and read it back into Applilet for further modification without deleting or breaking your additions.
“雙向工程”是該Applilet的一項極具價值的特性怖辆,你可以使用Applilet生成代碼删顶,添加自己編寫的代碼淑廊,然后讀回到Applilet中作進一步的修正,而不會把你添加的代碼刪掉或者打亂季惩。
In order to configure all port bits of a port as outputs, we need to check “Out” for each port bit.
若要將一個端口的所有位配置成輸出,需要將每一位都選中“Out”画拾。
we can specify the initial value of the output bits as one (by checking the “1? box) or zero (by leaving it unchecked).
輸出位的初始值可以設置為1(選中復選框1)或者0(復選框不選中)。
The code generated by Applilet after we press “Generate Code” can be viewed by selecting the “File” tab next to “Module” and navigating the file tree view of the generated files.
按“生成代碼”后Applilet生成的代碼可以選擇在“模塊”旁邊的“文件”標簽頁中進行瀏覽青抛。
/*
Port Register (Pm)
*/
/* Pmn pin data (Pm0 to Pm7) */
#define _00_Pn0_OUTPUT_0 (0x00U) /* Pn0 output 0 */
#define _01_Pn0_OUTPUT_1 (0x01U) /* Pn0 output 1 */
#define _00_Pn1_OUTPUT_0 (0x00U) /* Pn1 output 0 */
#define _02_Pn1_OUTPUT_1 (0x02U) /* Pn1 output 1 */
#define _00_Pn2_OUTPUT_0 (0x00U) /* Pn2 output 0 */
#define _04_Pn2_OUTPUT_1 (0x04U) /* Pn2 output 1 */
#define _00_Pn3_OUTPUT_0 (0x00U) /* Pn3 output 0 */
#define _08_Pn3_OUTPUT_1 (0x08U) /* Pn3 output 1 */
#define _00_Pn4_OUTPUT_0 (0x00U) /* Pn4 output 0 */
#define _10_Pn4_OUTPUT_1 (0x10U) /* Pn4 output 1 */
#define _00_Pn5_OUTPUT_0 (0x00U) /* Pn5 output 0 */
#define _20_Pn5_OUTPUT_1 (0x20U) /* Pn5 output 1 */
#define _00_Pn6_OUTPUT_0 (0x00U) /* Pn6 output 0 */
#define _40_Pn6_OUTPUT_1 (0x40U) /* Pn6 output 1 */
#define _00_Pn7_OUTPUT_0 (0x00U) /* Pn7 output 0 */
#define _80_Pn7_OUTPUT_1 (0x80U) /* Pn7 output 1 */
解釋含義
_00_Pn0_OUTPUT_0 代表:
- _00: 符號的實際值 (0x00)
- _Pn0: 端口寄存器第0位(no0)
- _OUTPUT_0: 輸出值為 0
同樣, _02_Pn1_OUTPUT_1 代表: - _02: 符號的實際值 (0x02)
- _Pn1: 端口寄存器第1位(n1)
- _OUTPUT_1: 輸出值為 1
/*
Port Mode Register (PMm)
*/
/* Pmn pin I/O mode selection (PMm7 - PMm0) */
#define _01_PMn0_NOT_USE (0x01U) /* not use Pn0 as digital I/O */
#define _01_PMn0_MODE_INPUT (0x01U) /* use Pn0 as input mode */
#define _00_PMn0_MODE_OUTPUT (0x00U) /* use Pn0 as output mode */
#define _02_PMn1_NOT_USE (0x02U) /* not use Pn1 as digital I/O */
#define _02_PMn1_MODE_INPUT (0x02U) /* use Pn1 as input mode */
#define _00_PMn1_MODE_OUTPUT (0x00U) /* use Pn1 as output mode */
#define _04_PMn2_NOT_USE (0x04U) /* not use Pn2 as digital I/O */
#define _04_PMn2_MODE_INPUT (0x04U) /* use Pn2 as input mode */
#define _00_PMn2_MODE_OUTPUT (0x00U) /* use Pn2 as output mode */
#define _08_PMn3_NOT_USE (0x08U) /* not use Pn3 as digital I/O */
#define _08_PMn3_MODE_INPUT (0x08U) /* use Pn3 as input mode */
#define _00_PMn3_MODE_OUTPUT (0x00U) /* use Pn3 as output mode */
#define _10_PMn4_NOT_USE (0x10U) /* not use Pn4 as digital I/O */
#define _10_PMn4_MODE_INPUT (0x10U) /* use Pn4 as input mode */
#define _00_PMn4_MODE_OUTPUT (0x00U) /* use Pn4 as output mode */
#define _20_PMn5_NOT_USE (0x20U) /* not use Pn5 as digital I/O */
#define _20_PMn5_MODE_INPUT (0x20U) /* use Pn5 as input mode */
#define _00_PMn5_MODE_OUTPUT (0x00U) /* use Pn5 as output mode */
#define _40_PMn6_NOT_USE (0x40U) /* not use Pn6 as digital I/O */
#define _40_PMn6_MODE_INPUT (0x40U) /* use Pn6 as input mode */
#define _00_PMn6_MODE_OUTPUT (0x00U) /* use Pn6 as output mode */
#define _80_PMn7_NOT_USE (0x80U) /* not use Pn7 as digital I/O */
#define _80_PMn7_MODE_INPUT (0x80U) /* use Pn7 as input mode */
#define _00_PMn7_MODE_OUTPUT (0x00U) /* use Pn7 as output mode */
解釋含義
- _00_PMn0_MODE_OUTPUT 代表:
- _00: 符號的實際值 (0x00)
- _Pmn0: 端口狀態(tài)寄存器第0位(no0)
- _MODE_OUTPUT: 輸出位
同樣, _01_PMn0_MODE_INPUT 代表: - _01: 符號的實際值 (0x01)
- _PMn0: 端口狀態(tài)寄存器第0位
- _MODE_INPUT: 輸入位
詞匯
- sink currents,反向電流
- Servos适室,伺服電機
- Stepper motors,步進馬達
- level converter捣辆,電平變換器
- comparator,比較器
- quantization汽畴,數(shù)字化
- polling,輪詢
Pulse Width Modulation###
A common method for controlling the speed of a simple DC motor or the brightness of an LED is Pulse Width Modulation. Pulse Width Modulation works as a DAC by changing the duty cycle of an oscillating digital output as shown in Figure 2.20. In the case of an LED, the more time the duty cycle is HIGH, the brighter the LED. This method works in cases where the oscillating frequency is so fast that the resulting output seems smooth. The LED is actually turning on and off many tens of times per second; however, the human eye cannot
detect the independent flashes of the LED due to their speed. Motor speed can be controlled this way because the inertia of the spinning armature carries the motor forward through the moments when no power is applied. A PWM signal is typically generated by a timer peripheral which sets or clears the output signal when the internal counter reaches configurable count values.
控制簡單直流電機的轉(zhuǎn)速整袁,或者LED亮度的普通方法是PWM,PWM通過改變震蕩數(shù)字輸出的占空比按DAC工作坐昙,對于LED來說绳匀,高占空比的時間越長炸客,LED越亮,實際上LED每秒鐘點亮熄滅次數(shù)太高痹仙,這樣的高速人眼根本不能反應過來。馬達的控制也是一樣开仰。計時器外設產(chǎn)生PWM信號拟枚。