diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/peripheral_main.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/peripheral_main.c index 32abfc2..b7b0179 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/peripheral_main.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/peripheral_main.c @@ -307,10 +307,11 @@ int main(void) PRINT("%s\n", VER_LIB); PRINT("SystemCoreClock:%d\n", SystemCoreClock); /* ===== 实验: 禁用全部 Flash/SPI 操作 (2026-08-12) ===== - 目的: 验证 SPI 操作是否触发复位循环 (UART2 隔离后依旧复位+乱码, - 乱码紧跟 offlog_boot 的 SPI 写, 疑似 SPI 信号串扰 NRST/调试线) - #if 1 = 跳过全部 SPI; 通过后改 0 或删除本块恢复 */ -#if 1 + 结论: 禁用后设备稳定 → SPI 操作触发复位+乱码实锤 + 软件缓解: storage.c SPI 时钟降档 + GPIO 缓边沿 (见 SPI_Flash_Init) + 硬件根治: NRST 加 100nF 电容 / SPI 走线远离 NRST / 串阻缓边沿 + #if 0 = 恢复全部 SPI; 保留本块便于回退实验 */ +#if 0 PRINT("ISOLATE: flash/SPI disabled (flash isolation test)\n"); #else GetMacAddr(gMacAddr); @@ -341,9 +342,9 @@ int main(void) uart_init(); /* ===== 实验: 禁用 UART2 (Loop 口) 隔离测试 (2026-08-12) ===== - 目的: 验证 Loop MCU 数据/干扰是否导致复位循环 (RST_REASON 全 0 瞬态复位) - 做法: USART2 关断 + PA3 脱离 UART 功能(上拉输入) — 等效软件断开 Loop - 通过后删除此块; 另: 禁用后快照无帧入队, 同步验证快照 SPI 活动非诱因 */ + 结论: UART2 禁用后仍复位 → 与 Loop 数据路径无关 (后定位为 SPI 串扰) + #if 0 = 恢复 UART2 正常 */ +#if 0 { GPIO_InitTypeDef gpio; USART_ITConfig(USART2, USART_IT_RXNE, DISABLE); @@ -355,6 +356,7 @@ int main(void) GPIO_Init(GPIOA, &gpio); PRINT("ISOLATE: UART2 disabled (Loop isolation test)\n"); } +#endif TIM3_Init(); TIM2_Init(); diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/storage.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/storage.c index 87d7e56..8038b6c 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/storage.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/storage.c @@ -90,13 +90,13 @@ void SPI_Flash_Init(void) GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_SetBits(GPIOA, GPIO_Pin_4); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; @@ -105,7 +105,7 @@ void SPI_Flash_Init(void) GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; @@ -114,7 +114,7 @@ void SPI_Flash_Init(void) SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; - SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; + SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI1, &SPI_InitStructure);