我有一段代码应该在按下按钮(而不是在引导引脚上)打开电源时将电路板变成引导加载程序模式。
blah blah
int main(void)
{
delay(1000);
#ifdef ENABLE_OVERCLOCK
clk_init();
#endif
#if defined(RX_SBUS_DSMX_BAYANG_SWITCH)
switch_key();
if(KEY ==0)
{
unsigned long time=0;
while(KEY == 0)
{
if (time > 4000000)
{//reboot to dfu if the key is continiously held on poweron
__enable_irq();
RCC_DeInit();
SysTick->CTRL = SysTick->LOAD = SysTick->VAL = 0;
SYSCFG->CFGR1 = 0x01;
const uint32_t p = (*((uint32_t *) 0x1FFFC400));
__set_MSP(p);
void (*SysMemBootJump)(void);
SysMemBootJump = (void (*)(void)) (*((uint32_t *) 0x1FFFC404));
SysMemBootJump();
while(1);
}
++time;
}
blah blah
...等等。但是,运行此代码时,uC 挂起并且没有被 USB 检测到。我究竟做错了什么?