1.我现在测的是TAMPER_PIN0脚,上拉了10K电阻到后备电池的3V正极上,通过把这个管脚接GND来进行触发
2.我的初始化代码如下:
dryice_init(); //这里面会清DRY_SR的DTF和TAF位
//
dryice_enable_clock_and_prescaler(ENABLE);
dryice_active_tamper_config(ACTIVE_TAMPER_0,active_tamper_polynomial,active_tamper_shift_reg);
//
dryice_tamper_pin_direction_config(TAMPER_PIN0,INPUT); // TAMPER_PIN0设为输入
dryice_tamper_pin_expect_config(TAMPER_PIN0,LOGIC_ZERO); // TAMPER_PIN0的预期值是 0
dryice_tamper_pin_pull_config(TAMPER_PIN0,ENABLE); // TAMPER_PIN0的拉使能
dryice_tamper_pin_polarity_config(TAMPER_PIN0,INVERTED); // TAMPER_PIN0反转
glitch_filter_prescaler_switch(TAMPER_PIN0,DISABLE); //干扰滤波器禁用
glitch_filter_width_select(TAMPER_PIN0,10); //配置干扰滤波宽度
glitch_filter_prescaler_select(TAMPER_PIN0,PRESCALER_CLK_512_HZ); //配置预分频器选择
glitch_filter_prescaler_switch(TAMPER_PIN0,ENABLE); //使能干扰滤波器
dryice_pin_tamper_config(TAMPER_PIN0,ENABLE); //Tamper Pin Enable 管脚
dryice_int_tamper_config(9, DISABLE); //Test Mode Enable
dryice_int_tamper_config(8, DISABLE); //Flash Security Enable
dryice_int_tamper_config(7, ENABLE); //Security Tamper Enable
dryice_int_tamper_config(6, ENABLE); //Temperature Tamper Enable 温度
dryice_int_tamper_config(5, ENABLE); //Clock Tamper Enable 时钟
dryice_int_tamper_config(4, ENABLE); //Voltage Tamper Enable 电压
dryice_int_tamper_config(3, ENABLE); //Monotonic Overflow Enable
dryice_int_tamper_config(2, ENABLE); //Time Overflow Enable
//
DRY_CR |= DRY_CR_TFSR_MASK; //Tamper Force System Reset
3.实测拉低TAMPER_PIN0后确实是触发了,芯片自动复位,32字节RAM自动清空了了,但读出来
dryice_tmp = DRY_SR & DRY_SR_TPF_MASK; //Tamper Pin Flag 还是0,应该PIN0那个位置1才对呀
4.发现第一次上电没初始化时读取DTF和TAF两个位就已经是1了,就是说一上电就已经触发了
dryice_tmp = DRY_SR & DRY_SR_DTF_MASK; //DryIce Tamper Flag
dryice_tmp = DRY_SR & DRY_SR_TAF_MASK; //Tamper Acknowledge Flag
我怎么分辨是第一次上电导致的触发,还是真的tamper管脚触发的呢,我读了其他DRY_SR标志位,也全是0
dryice_tmp = DRY_SR & DRY_SR_DTF_MASK; //DryIce Tamper Flag
dryice_tmp = DRY_SR & DRY_SR_TAF_MASK; //Tamper Acknowledge Flag
dryice_tmp = DRY_SR & DRY_SR_TPF_MASK; //Tamper Pin Flag
dryice_tmp = DRY_SR & DRY_SR_TMF_MASK; //Test Mode Flag
dryice_tmp = DRY_SR & DRY_SR_FSF_MASK; //Flash Security Flag
dryice_tmp = DRY_SR & DRY_SR_STF_MASK; //Security Tamper Flag
dryice_tmp = DRY_SR & DRY_SR_TTF_MASK; //Temperature Tamper Flag
dryice_tmp = DRY_SR & DRY_SR_CTF_MASK; //Clock Tamper Flag
dryice_tmp = DRY_SR & DRY_SR_VTF_MASK; //Voltage Tamper Flag
dryice_tmp = DRY_SR & DRY_SR_MOF_MASK; //Monotonic Overflow Flag
dryice_tmp = DRY_SR & DRY_SR_TOF_MASK; //Time Overflow Flag
谢谢!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
Sorry,没有看到你的问题,
建议你创建SR,以获得技术支持!
http://www.amobbs.com/thread-5570020-1-1.html
一周热门 更多>