CH32V203F8P6 內(nèi)存中的數(shù)據(jù)莫名其妙的被篡改的問(wèn)題

如下圖所示, 該問(wèn)題也是不定時(shí)會(huì)發(fā)生的, 我在使用WCH-Link調(diào)試時(shí)遇到的:

image.png



如上代碼所示, GlobalData是我自定義的結(jié)構(gòu)體, 并且是全局變量, 上面剛用memset修改完GlobalData, 并初始化了兩個(gè)字段,?

在下面printf處打印出來(lái), 就已經(jīng)不是上面修改過(guò)的值了, 不知在哪里被篡改了...

部分代碼如下:

typedef?struct?__attribute__((aligned(4)))?_GLOBAL_DATA_S?{
????uint16_t????????magic;
????uint16_t????????version;
????uint32_t????????flags;
????float???????????ADC1_sense_volt_fp;
????float???????????ADC2_sense_volt_fp;
????float???????????ADC1_vagc_volt_fp;
????uint16_t????????ADC1_sense_volt;
????uint16_t????????ADC2_sense_volt;
????uint16_t????????ADC1_vagc_volt;
????uint16_t????????ADC1_vntc_volt;
????uint16_t????????ADC1_vtmp_volt;
????uint8_t?????????ADC2_PgaGain;
????int8_t??????????tia_temp;
????int8_t??????????mcu_temp;
????int8_t??????????tia_init_temp;
????int8_t??????????mcu_init_temp;
}?GLOBAL_DATA_T,?*PGLOBAL_DATA_T;


void?Init_Periph(void)
{
????RCC_HCLKConfig(RCC_SYSCLK_Div1);
????RCC_PCLK1Config(RCC_HCLK_Div2);
????RCC_PCLK2Config(RCC_HCLK_Div1);
????RCC_ADCCLKConfig(RCC_PCLK2_Div8);

????RCC_APB1PeriphClockCmd(
????????????RCC_APB1Periph_USART2?|
????????????RCC_APB1Periph_TIM3
????????????,?ENABLE);

????RCC_APB2PeriphClockCmd(
????????????RCC_APB2Periph_GPIOA?|
????????????RCC_APB2Periph_GPIOB?|
????????????RCC_APB2Periph_ADC1?|
????????????RCC_APB2Periph_ADC2?|
????????????RCC_APB2Periph_TIM1?|
????????????RCC_APB2Periph_AFIO
????????????,?ENABLE);
}

int?main(void)
{
????int?i,?sum;
????uint32_t?u32;
????uint16_t?u16buf[16];
????float?favg;
????uint16_t?avg;

????NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
????Init_Periph();
????Delay_Init();
????Init_GPIO();
????USART_Printf_Init(115200);

????memset(&GlobalData,?0,?sizeof(GLOBAL_DATA_T));
????GlobalData.magic?=?0x55AA;
????GlobalData.version?=?1;

#if?0
????GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,?ENABLE);
#endif

????printf("SystemClk:%d\r\n",?SystemCoreClock);

????Delay_Ms(1);

????//AGC_PWMOut_Init(?4095,?16-1,?3685?);?//?≈2940mv
????AGC_PWMOut_Init(?4095,?16-1,?3685?);?//?≈2954mv
????SetPowerControl(0);
????SetLedState(1);

????Delay_Ms(1);
????
????//?......
}



只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频