のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

CALL HAL handlerを有効にすると

port.c

void xPortSysTickHandler( void )
{
    /* The SysTick runs at the lowest interrupt priority, so when this interrupt
   executes all interrupts must be unmasked.  There is therefore no need to
   save and then restore the interrupt mask value as its value is already
   known. */
    portDISABLE_INTERRUPTS();
    {
        /* Increment the RTOS tick. */
        if( xTaskIncrementTick() != pdFALSE )
        {
            /* A context switch is required.  Context switching is performed in
           the PendSV interrupt.  Pend the PendSV interrupt. */
            portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
        }
    }
    portENABLE_INTERRUPTS();
}
/*-----------------------------------------------------------*/

CALL HAL handlerを有効にすると、こちらが呼ばれる。 stm32fxx_it.c

/**
  * @brief This function handles System tick timer.
  */
void SysTick_Handler(void)
{
  /* USER CODE BEGIN SysTick_IRQn 0 */

  /* USER CODE END SysTick_IRQn 0 */
  HAL_IncTick();
  
  /* USER CODE BEGIN SysTick_IRQn 1 */

  /* USER CODE END SysTick_IRQn 1 */
}

f:id:none53:20190717083126p:plain

タスクのスタックサイズをわざと、小さくしたとき

Stackをわざと、必要な容量より小さい、128に設定して動作させてみた。 myTask01のスタック領域が壊れている。 HardFaultになった。

Sta

f:id:none53:20190717062945p:plain
Stack破壊のときの例

f:id:none53:20190717063349p:plain
必要な容量

タイマタスクのスタックサイズが200のとき、myTask01のTCBが壊れている。

f:id:none53:20190717064506p:plain
mytask01のスタックが壊れている

myTask01,myTask02のスタックサイズは64にしてある。 myTask02が、myTask01のスタックを壊しているみたいだ。

f:id:none53:20190717064839p:plain
初期化時