Half Complete flag bug in DMAChannel_LDD

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Half Complete flag bug in DMAChannel_LDD

跳至解决方案
830 次查看
bowerymarc
Contributor V

looks like setting "Initialization->Half complete" to Enabled does not OR in DMA_CSR_INTHALF_MASK as it should.

标签 (1)
标记 (2)
0 项奖励
1 解答
478 次查看
Petr_H
NXP Employee
NXP Employee

Hi,

Yes, we confirm that it's a bug, this option doesn't work properly. We are working on the fix for the next release.

We are sorry for an inconvenience. For now, the following workaround can be applied:

1) Set properties according to your request.
2) Enable GetTransferCompleteStatus() method generation.
3) Generate code

4)Disable generation of DMAChannel_LDD and DMAController components using the context (pop-up) menu option Code geration > Don't Write Generated Code Modules.

5) Open DMACH1.c generated  by DMAChannnel_LDD component

6) Find DMA1_TChnInit const DMACH1_ChInit structure and
    add DMA_CSR_INTHALF_MASK constant to the  TCD_CSR register initial value item.
    (see attached picture)

7) Open DMA1.c generated by DMAController component.

8) Find static void HandleInterrupt(DMA1_TChnDevData *ChnDevDataPtr) and
    add following code after last "} else {" statement: (see attached picture)

    DMA1__ClearChannelInterruptFlag(DmaMemMapPtr, ChnDevConstPtr->PhyChnNum);
    if (ChnDevDataPtr->Events.OnCompleteFnPtr != NULL) {
      ChnDevDataPtr->Events.OnCompleteFnPtr(ChnDevDataPtr->UserDataPtr);
    }

9) In DMACH1_OnComplete() event you can use following code in order to distinguish "Full complete" and "Half complete" event.

void DMACH1_OnComplete(LDD_TUserData *UserDataPtr)
{
  if (DMACH1_GetTransferCompleteStatus(hDmaChn) == FALSE) {
    /* FullComplete = FALSE;    HalfComplete = TRUE;  */
  } else {
    /* FullComplete = TRUE;    HalfComplete = FALSE;  */
  }
}

Note: If interrupts are disabled or your code doesn't handle OnComplete event before all data are transferred by DMA peripheral, OnComplete event will be invoked only once and GetTransferCompleteStatus() called from this event will always return TRUE = "Full complete".

Best regards

Petr Hradsky

Processor Expert Support Team

在原帖中查看解决方案

0 项奖励
4 回复数
478 次查看
scottm
Senior Contributor II

It's been 3 years and the component doesn't seem to be fixed yet.  Was there a release that I missed?  I'm running CW 10.7, and the component shows up as version 01.051.

Thanks,

Scott

0 项奖励
479 次查看
Petr_H
NXP Employee
NXP Employee

Hi,

Yes, we confirm that it's a bug, this option doesn't work properly. We are working on the fix for the next release.

We are sorry for an inconvenience. For now, the following workaround can be applied:

1) Set properties according to your request.
2) Enable GetTransferCompleteStatus() method generation.
3) Generate code

4)Disable generation of DMAChannel_LDD and DMAController components using the context (pop-up) menu option Code geration > Don't Write Generated Code Modules.

5) Open DMACH1.c generated  by DMAChannnel_LDD component

6) Find DMA1_TChnInit const DMACH1_ChInit structure and
    add DMA_CSR_INTHALF_MASK constant to the  TCD_CSR register initial value item.
    (see attached picture)

7) Open DMA1.c generated by DMAController component.

8) Find static void HandleInterrupt(DMA1_TChnDevData *ChnDevDataPtr) and
    add following code after last "} else {" statement: (see attached picture)

    DMA1__ClearChannelInterruptFlag(DmaMemMapPtr, ChnDevConstPtr->PhyChnNum);
    if (ChnDevDataPtr->Events.OnCompleteFnPtr != NULL) {
      ChnDevDataPtr->Events.OnCompleteFnPtr(ChnDevDataPtr->UserDataPtr);
    }

9) In DMACH1_OnComplete() event you can use following code in order to distinguish "Full complete" and "Half complete" event.

void DMACH1_OnComplete(LDD_TUserData *UserDataPtr)
{
  if (DMACH1_GetTransferCompleteStatus(hDmaChn) == FALSE) {
    /* FullComplete = FALSE;    HalfComplete = TRUE;  */
  } else {
    /* FullComplete = TRUE;    HalfComplete = FALSE;  */
  }
}

Note: If interrupts are disabled or your code doesn't handle OnComplete event before all data are transferred by DMA peripheral, OnComplete event will be invoked only once and GetTransferCompleteStatus() called from this event will always return TRUE = "Full complete".

Best regards

Petr Hradsky

Processor Expert Support Team

0 项奖励
478 次查看
bowerymarc
Contributor V

Thanks Petr for verifying.

You forgot to attach the picture...

0 项奖励
478 次查看
Petr_H
NXP Employee
NXP Employee

I'm sorry, you are right, here it is:

DMA_HalfComplete_Fix.jpg

 

Best regards

Petr Hradsky

Processor Expert Support Team

0 项奖励