Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

possible error in stm32_ll_lpbam.c

未关闭
#65 9 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@MKISTM 已经在做这个了。

开始于 2026年5月8日。

  • #73 来自 @94xhn —— 已关闭,未合并
  • #74 来自 @94xhn —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

bug internal bug tracker lpbam utils
LPBAM_Status_t LPBAM_LPTIM_FillNodeConfig(LPBAM_LPTIM_ConfNode_t const *const  pConfNode,
                                          DMA_NodeConfTypeDef    *const pDMANodeConfig)
{
  LPBAM_Status_t   status;
  LPBAM_InfoDesc_t desc_info;
  ...

in stm32_lpbam_lptim.c leaves desc_info uninitialized and calls

LPBAM_Status_t LPBAM_LPTIM_FillStructInfo(LPBAM_LPTIM_ConfNode_t const *const pConfNode,
                                          LPBAM_InfoDesc_t       *const pDescInfo)

in stm32_ll_lpbam.c with reference to desc_info.

While LPBAM_LPTIM_FillStructInfo does not set pDescInfo->Request in case of LPBAM_LPTIM_CONFIG_ID with pConfNode->Config.State != ENABLE and pConfNode->Config.Mode != LPBAM_LPTIM_UE_MODE as it can be seen in the following code snippet.

  ...
  /* Check node ID */
  switch (pConfNode->NodeDesc.NodeInfo.NodeID)
  {
    /* LPBAM LPTIM Update Period node ID */
    case LPBAM_LPTIM_CONFIG_ID:
    {
      /* Get control register value */
      dummy = pConfNode->pInstance->CR;

      /* Check LPTIM state */
      if (pConfNode->Config.State == ENABLE)
      {
        /* Set LPTIM update event request */
        pDescInfo->Request = DMA_REQUEST_SW;

        /* Set LPTIM state */
        dummy |= LPTIM_CR_ENABLE;

        /* Check LPTIM start mode update */
        if (pConfNode->Config.UpdateStartMode == ENABLE)
        {
          if (pConfNode->Config.StartMode == LPBAM_LPTIM_START_SINGLE)
          {
            /* Configure LPTIM to start in single mode */
            dummy |= LPTIM_CR_SNGSTRT;
          }
          else
          {
            /* Configure LPTIM to start in continuous mode */
            dummy |= LPTIM_CR_CNTSTRT;
          }
        }
      }
      else
      {
        /* Set LPTIM state */
        dummy &= ~(LPTIM_CR_ENABLE);
    	
        /* Check LPTIM mode */
        if (pConfNode->Config.Mode == LPBAM_LPTIM_UE_MODE)
        {
          /* Check LPTIM instance */
          if (pConfNode->pInstance == LPTIM1)
          {
            /* Set LPTIM1 update event request */
            pDescInfo->Request = LPDMA1_REQUEST_LPTIM1_UE;
          }
          else
          {
            /* Set LPTIM3 update event request */
            pDescInfo->Request = LPDMA1_REQUEST_LPTIM3_UE;
          }
        }
      }

      /* Set value to be written */
      *pConfNode->NodeDesc.pSrcVarReg = dummy;

      /* Set DMA source address */
      pDescInfo->SrcAddr  = (uint32_t)pConfNode->NodeDesc.pSrcVarReg;
      /* Set DMA destination address */
      pDescInfo->DstAddr  = lptim_descitem_tbl[pConfNode->NodeDesc.NodeInfo.NodeID].RegOffset +
                            (uint32_t)pConfNode->pInstance;
      /* Set DMA data size */
      pDescInfo->DataSize = lptim_descitem_tbl[pConfNode->NodeDesc.NodeInfo.NodeID].RegDataSize;

      break;
    }
    ....

Later code uses Request leading to undefined behavior. The fix that worked for me was adding

      ...
      else
      {
        
        pDescInfo->Request = DMA_REQUEST_SW;

        /* Set LPTIM state */
        dummy &= ~(LPTIM_CR_ENABLE);
      ...

essentially this problem occurred when adding a lptim stop node with "not from update event detection" in cubemx lpbam scenario.

主要语言
C
星标
184
派生
94
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

STMicroelectronics/STM32CubeU5 的其他 Issue

查看 STMicroelectronics/STM32CubeU5 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。