R8记录

——When do initiation for mcu module,must disable interrupt flag.

——When change interrupt control register, must according the code guild in the spec.take special care.

—— MCU coding

1,  use pointers in the subroutine instead of citing the variables.( 形参用指针的形式也是一个道理)

2, initialization executed at the definition will save more ROM space than performed in the subroutine.

1.I/O初始化

///initialization for IO ports and direction registers and mode registers.

///notice the protective register for Pd0. p2drr, and pull up registers.

2,串行异步通信

///使用On-chip仿真器时,仿真器需要占用一些ROM(2Kbytes)RAM(128bytes)的资源,且UART1的功能不能使用。

—— IIC coding,SDA, SCL, I/O模拟I2C 

SCL is set as output, SDA is set as input. When do IO port initiation. And the initial value is set as 1 and 0;   // use I/O to simulate I2C.

——MCU clock

there are a CPU clock to operate the CPU, and a peripheral function clock to operate the peripheral functions.

the system clock is the clock source for the CPU and peripheral function clocks. Either the Xin clock or the on-chip oscillator clock can be selected.

one cycle of the instruction execution time equals to one clock of the CPU clock, which came from dividing the system clock by 2. So the nop statement, one cycle of the instruction execution, one clock of the CPU clock, is half the system clock(xin时钟的2个周期);

——看门狗

 

Use the frequency with the max count value get the time of watch dog reset.

 

 ——仿真

—E8 see time interverence, view , cpu , status. But,如果不用软件仿真,而是烧在片子里,上面的方法不能看时间。

 

http://www.renesasrulz.com/thread/4111 Clocks Cycles/time are display in the trace under Menu View -> Trace window to show elapsed time between trace or break points. 

10. 仿真执行过程中的存储器存取

引用或修改存储器内容时,用户程序会暂停。因此,无法执行实时仿真。如果必须在程序执行期间进行实时仿真,则应在运行程序之前,在监视窗口中禁止自动更新,或者固定存储器窗口中的显示,以确保在执行过程中不会发生存储器存取。

//所以有时时间数据表现不符

 12. 调试时, E8a 仿真器会频繁地重写闪存。因此,请勿在产品中使用已用于调试的 MCU。此外,由于在调试过程中 E8a 仿真器程序会被写入 MCU,因此请不要保存用于调试的 MCU 闪存内容,也不要将它们用作产品的 ROM 数据。

 15. 在停止模式或等待模式下进行调试

在停止模式或等待模式下, E8a 仿真器无法停止程序。如果尝试在停止模式或等待模式下停止程序,仿真器将无法控制 MCU。

在程序遇到断点而停止之前,不宜在屏幕上作更动。此断点是取消停止模式或等待模式后在程序行上设置的。

如果在用户程序中使用停止模式或等待模式,则应在运行程序之前,在监视窗口中禁止自动更新,或者固定存储器窗口中的显示,以确保在执行过程中不会发生存储器存取。

 16. 暂停期间的外围 I/O

用户程序暂停期间,尽管外围 I/O 继续运行,但不接受中断。例如,定时器启动后,在用户程序由于遇到断点而停止时,定时器会继续计数,但不接受定时器中断。

 

 这个文档对深入理解R8系统很有帮助 C Program Guidelines of R8CTiny Series

 

 

原文地址:https://www.cnblogs.com/aprilapril/p/2961613.html