0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

STM32CubeでFreeRTOS使用時のHardFault対策

Posted at

はじめに

STM32CubeMXやSTM32CubeIDEでFreeRTOSを組み込んだプロジェクトを作成し、
ブートローダから起動させるとHardFaultになることが有ります。

void HardFault_Handler(void)
{
  while (1)
  {
  }
}

原因

FreeRTOSはSysTickによってOSを動かしています。
ブートローダでSysTick割り込みを有効にしたままアプリをロードしてしまうと、FreeRTOSの初期化に到達する前にSysTick割り込みが起こり不正メモリアクセスでHardFaultになります。

対策

ブートローダでアプリをロードする前にSysTickを停止させます。

...
HAL_SuspendTick();
JumpToAPP();
0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?