问题STM32F103RC系列,使用虚拟串口时,一直跳转到
void Suspend(void)
{
uint32_t i =0;
uint16_t wCNTR;
uint32_t tmpreg = 0;
__IO uint32_t savePWR_CR=0;
/* suspend preparation */
/* ... */
/*Store CNTR value */
wCNTR = _GetCNTR();
/* This a sequence to apply a force RESET to handle a robustness case */
/*Store endpoints registers status */
for (i=0;i<8;i++) EP[i] = _GetENDPOINT(i);
/* unmask RESET flag */
wCNTR|=CNTR_RESETM;
_SetCNTR(wCNTR);
/*apply FRES */
wCNTR|=CNTR_FRES;
_SetCNTR(wCNTR);
/*clear FRES*/
wCNTR&=~CNTR_FRES;
_SetCNTR(wCNTR);
/*poll for RESET flag in ISTR*/
while((_GetISTR()&ISTR_RESET) == 0);
/* clear RESET flag in ISTR */
_SetISTR((uint16_t)CLR_RESET);
/*restore Enpoints*/
for (i=0;i<8;i++)
_SetENDPOINT(i, EP[i]);
/* Now it is safe to enter macrocell in suspend mode */
wCNTR |= CNTR_FSUSP;
_SetCNTR(wCNTR);
/* force low-power mode in the macrocell */
wCNTR = _GetCNTR();
wCNTR |= CNTR_LPMODE;
_SetCNTR(wCNTR);
/*prepare entry in low power mode (STOP mode)*/
/* Select the regulator state in STOP mode*/
savePWR_CR = PWR->CR;
tmpreg = PWR->CR;
/* Clear PDDS and LPDS bits */
tmpreg &= ((uint32_t)0xFFFFFFFC);
/* Set LPDS bit according to PWR_Regulator value */
tmpreg |= PWR_Regulator_LowPower;
/* Store the new value */
PWR->CR = tmpreg;
/* Set SLEEPDEEP bit of Cortex System Control Register */
#if defined (STM32F30X) || defined (STM32F37X)
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
#else
SCB->SCR |= SCB_SCR_SLEEPDEEP;
#endif
/* enter system in STOP mode, only when wakeup flag in not set */
if((_GetISTR()&ISTR_WKUP)==0)
{
__WFI();
/* Reset SLEEPDEEP bit of Cortex System Control Register */
#if defined (STM32F30X) || defined (STM32F37X)
SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
#else
SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP);
#endif
我停止全速跑时,就会停止在
SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP); 这里,使用系统休眠了,我没有让系统休眠!!!谢谢,那位能帮助解决一下。 |