18785275440 发表于 2022-3-10 13:07

n32g457在rtt中使用us函数造成程序卡死

这是us延时函数
void delay_us(rt_uint32_t nus)
{
      u32 temp;
      SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);    //select system clock
      SysTick->LOAD=nus*(SystemCoreClock/(1000000/RT_TICK_PER_SECOND)); //time relode
      SysTick->VAL=0x00;      //clear timer value
      SysTick->CTRL|=SysTick_CTRL_ENABLE_Msk ;//Start countdown
      do
      {
            temp=SysTick->CTRL;
      }
      while(temp&0x01&&!(temp&(1<<16)));//wait for the time reach
      SysTick->CTRL&=~SysTick_CTRL_ENABLE_Msk;       //close the count
      SysTick->VAL =0X00;       //clear timer value

}


msh > Warning: There is no enough buffer for saving data, please increase the RT_SERIAL_RB_BUFSZ option.
list_thread
thread   pristatus      sp   stack size max used left tickerror
-------- ---------- ---------- -------------------------- ---
serial3    9suspend 0x000000a4 0x00000400    16%   0x0000000a 000
serial   9suspend 0x000000b4 0x00000400    17%   0x0000000a 000
motor      9suspend 0x000000ac 0x00000200    33%   0x0000000a 000
key      9suspend 0x000000b4 0x00000200    35%   0x0000000a 000
read_adc15suspend 0x000000bc 0x00000200    46%   0x0000000a 000
tshell    20running 0x000000cc 0x00001000    14%   0x0000000a 000
tidle0    31ready   0x00000074 0x00000100    45%   0x00000020 000
timer      4suspend 0x0000007c 0x00000200    24%   0x00000009 000
main      10suspend 0x000000b8 0x00000800    17%   0x00000007 000
msh >
页: [1]
查看完整版本: n32g457在rtt中使用us函数造成程序卡死