简体   繁体   English

系统重置时取消重置 GPIO 引脚

[英]Unreset GPIO Pins While System Resetting

Is it possible to unreset some GPIO pins while using NVIC_SystemReset function at STM32?在 STM32 上使用 NVIC_SystemReset function 时是否可以取消重置某些 GPIO 引脚? Thanks in advance for your answers提前感谢您的回答

Best Regards此致

I try to reach NVIC_SystemReset function.我尝试到达 NVIC_SystemReset function。 But not clear inside of this function.但不清楚这个function里面。 Also this project is running on KEIL这个项目也在KEIL上运行

Looks like it is not possible, NVIC_SystemReset issues a general reset of all subsystems.看起来不可能,NVIC_SystemReset 发出所有子系统的一般重置。

But probably, instead of system reset, you can just reset all peripheral expect one you need keep working, using peripheral reset registers in Reset and Clock Control module (RCC): RCC_AHB1RSTR , RCC_AHB2RSTR , RCC_APB1RSTR , RCC_APB1RSTR .但很可能,您可以使用复位和时钟控制模块 (RCC) 中的外设复位寄存器来复位所有外设,而不是系统复位,而是复位所有外设: RCC_AHB1RSTRRCC_AHB2RSTRRCC_APB1RSTRRCC_APB1RSTR

Example:例子:

   // Issue reset of SPI2, SPI3, I2C1, I2C2, I2C3 on APB1 bus
   RCC->APB1RSTR = RCC_APB1RSTR_I2C3RST | RCC_APB1RSTR_I2C2RST | RCC_APB1RSTR_I2C1RST 
                 | RCC_APB1RSTR_SPI3RST | RCC_APB1RSTR_SPI2RST;
   __DMB(); // Data memory barrier
   RCC->APB1RSTR = 0; // deassert all reset signals

See detailed information in RCC registers description in Reference Manual for your MCU.请参阅您的 MCU 参考手册中的RCC 寄存器描述中的详细信息。

You may also need to disable all interrupts in NVIC:您可能还需要禁用 NVIC 中的所有中断:

  for (int i = 0 ; i < 8 ; i++) NVIC->ICER[i] = 0xFFFFFFFFUL; // disable all interrupts 
  for (int i = 0 ; i < 8 ; i++) NVIC->ICPR[i] = 0xFFFFFFFFUL; // clear all pending flags

if you want to restart the program, you can reload stack pointer to its top value, located at offset 0 of the flash memory and jump to the start address which is stored at offset 4. Note: flash memory is addressed starting from 0x08000000 address in the address space. if you want to restart the program, you can reload stack pointer to its top value, located at offset 0 of the flash memory and jump to the start address which is stored at offset 4. Note: flash memory is addressed starting from 0x08000000 address in地址空间。

  uint32_t stack_top = *((volatile uint32_t*)FLASH_BASE);
  uint32_t entry_point = *((volatile uint32_t*)(FLASH_BASE + 4));

  __set_MSP(stack_top); // set stack top
  __ASM volatile ("BX %0" : : "r" (entry_point | 1) ); // jump to the entry point with bit 1 set

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM