本帖最后由 chongdongchen 于 2018-6-2 21:46 编辑
还是自己先实验吧,针对我刚刚提出的寄存器读取的两种方法,专门做了一个实验,主要程序如下:
<div>//读取寄存器值</div><div>uint16_t ReadRCTRIM(void)
</div>{
uint8_t hircmap0,hircmap1;
hircmap0 = RCTRIM0;
hircmap1 = RCTRIM1;
return (((uint16_t)hircmap0<<1)+(hircmap1&0x01));
}
<div>//手册方法</div><div>void MODIFY_HIRC_VLAUE_1(void)
</div>{
uint8_t hircmap0,hircmap1;
uint16_t trimvalue16bit;
set_IAPEN;
IAPAL = 0x30;
IAPAH = 0x00;
IAPCN = READ_UID;
set_IAPGO;
hircmap0 = IAPFD;
IAPAL = 0x31;
IAPAH = 0x00;
set_IAPGO;
hircmap1 = IAPFD;
clr_IAPEN;
trimvalue16bit = ((hircmap0<<1)+(hircmap1&0x01));
trimvalue16bit = trimvalue16bit - 15;
hircmap1 = trimvalue16bit&0x01;
hircmap0 = trimvalue16bit>>1;
TA=0XAA;
TA=0X55;
RCTRIM0 = hircmap0;
TA=0XAA;
TA=0X55;
RCTRIM1 = hircmap1;
<div>}</div><div>//直接寄存器法</div><div>void MODIFY_HIRC_VLAUE_2(void)
</div>{
uint8_t hircmap0,hircmap1;
uint16_t trimvalue16bit;
hircmap0 = RCTRIM0;
hircmap1 = RCTRIM1;
trimvalue16bit = ((hircmap0<<1)+(hircmap1&0x01));
trimvalue16bit = trimvalue16bit - 15;
hircmap1 = trimvalue16bit&0x01;
hircmap0 = trimvalue16bit>>1;
TA=0XAA;
TA=0X55;
RCTRIM0 = hircmap0;
TA=0XAA;
TA=0X55;
RCTRIM1 = hircmap1;
}
第一次实验(function函数1ms执行一次):
第一次进入断点(第5秒):
第二次进入断点(第6秒):
第三次,(第7秒):
接下来每次进中断都保持不变。
得出这次实验的结果:
手册方法:每次都是 0x010A - 0x15 = 0xF5;//这里为什么是减去0x15?再研究。。
寄存器法:每次都是寄存器自减 15;
|