Half Complete flag bug in DMAChannel_LDD

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Half Complete flag bug in DMAChannel_LDD

Jump to solution
793 Views
bowerymarc
Contributor V

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

Labels (1)
Tags (2)
0 Kudos
1 Solution
441 Views
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

View solution in original post

0 Kudos
4 Replies
441 Views
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 Kudos
442 Views
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 Kudos
441 Views
bowerymarc
Contributor V

Thanks Petr for verifying.

You forgot to attach the picture...

0 Kudos
441 Views
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 Kudos