RT685 CTimer0 callBack delayed

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

RT685 CTimer0 callBack delayed

3,979 Views
katte82
Contributor III

I modified the mimxrt685audevk_lpadc_dma_cm33 example from SDK 25.9 for MIMXRT685-AUD-EVK to create this chain:
CTIMER0 -> ADC -> DAC -> PingPongBuffer in RAM.
CTIMER0: 32kHz; ToggleBit on Match_CH_3
ADC0: Start on Trigger 5; Create interrupt for DMA every 16 samples (FIFO watermark = 15)
DMA0: PingPong; Start on Hardware trigger 24

I added Set/Clear pins to the callbacks for debugging.

From the pin log, it appears that the CTimer0 callback is delayed when the DMA is triggered, even though the DMA is executed at a time that does not overlap with the CTimer timing.

Can anyone tell me why this happens?

Labels (1)
0 Kudos
Reply
5 Replies

3,913 Views
mayliu1
NXP Employee
NXP Employee

Hi @katte82 ,

Thank you so much for your interest in our products and for using our community.

I suggest double checking the following points:

1:Set the NVIC priorities and try to assign a higher priority to CTIMER0 than DMA and ADC, then test again.

2:Verify that the transfer type is set to kDMA_PeripheralToMemory.

 

mayliu1_0-1764831075550.pngmayliu1_0-1764831075550.png

Best Regards

MayLiu

0 Kudos
Reply

3,907 Views
katte82
Contributor III
1) Setting the priority solves the problem. But I don't understand why it's necessary. In theory, the hardware has all the time it needs to handle the DMA callback.
2) I've tried many times, but if I switch to PeripheralToMemory, strange things happen and nothing works. The ADC still remain in interrupt and DMA never calls the callback. Maybe PeripheralToMemory don't handle correctly the watermark set to 15? Could using DMA in MemoryToMemory be a problem?

Thanks in advance.
Regards.
0 Kudos
Reply

3,810 Views
mayliu1
NXP Employee
NXP Employee

Hi @katte82 ,

Thanks for your updated information.

A1: It is necessary, because the callback runs in the interrupt service routine (ISR),  and NVIC priority decides who runs first. DMA/ADC ISR preempted CTIMER0, so the CTIMER0 callback was delayed.

A2: I suggest you can refer to SDK demo "evkmimxrt685_lpadc_dma_cm33"

Best Regards

MayLiu

0 Kudos
Reply

3,598 Views
katte82
Contributor III
Thanks for the hint.
1) I continue not understand why the ctimer interrupt need a greater priority. There are many "free usec" after DMA callback.

2) In example, the data flow is handled by the software.
I'm trying to configure the cpu to do all the hard work by itself.

Thanks and Best regards.
0 Kudos
Reply

3,540 Views
mayliu1
NXP Employee
NXP Employee

I think if the ctimer has a lower priority, its execution could be delayed, affecting timing precision and real time performance.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2254174%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERT685%20CTimer0%20callBack%20delayed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2254174%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20modified%20the%20mimxrt685audevk_lpadc_dma_cm33%20example%20from%20SDK%2025.9%20for%20MIMXRT685-AUD-EVK%20to%20create%20this%20chain%3A%3CBR%20%2F%3ECTIMER0%20-%26gt%3B%20ADC%20-%26gt%3B%20DAC%20-%26gt%3B%20PingPongBuffer%20in%20RAM.%3CBR%20%2F%3ECTIMER0%3A%2032kHz%3B%20ToggleBit%20on%20Match_CH_3%3CBR%20%2F%3EADC0%3A%20Start%20on%20Trigger%205%3B%20Create%20interrupt%20for%20DMA%20every%2016%20samples%20(FIFO%20watermark%20%3D%2015)%3CBR%20%2F%3EDMA0%3A%20PingPong%3B%20Start%20on%20Hardware%20trigger%2024%3C%2FP%3E%3CP%3EI%20added%20Set%2FClear%20pins%20to%20the%20callbacks%20for%20debugging.%3C%2FP%3E%3CP%3EFrom%20the%20pin%20log%2C%20it%20appears%20that%20the%20CTimer0%20callback%20is%20delayed%20when%20the%20DMA%20is%20triggered%2C%20even%20though%20the%20DMA%20is%20executed%20at%20a%20time%20that%20does%20not%20overlap%20with%20the%20CTimer%20timing.%3C%2FP%3E%3CP%3ECan%20anyone%20tell%20me%20why%20this%20happens%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2254174%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MXRT%20600%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2254902%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20RT685%20CTimer0%20callBack%20delayed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2254902%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F256644%22%20target%3D%22_blank%22%3E%40katte82%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EThank%20you%20so%20much%20for%20your%20interest%20in%20our%20products%20and%20for%20using%20our%20community.%3C%2FP%3E%0A%3CDIV%3E%0A%3CP%3EI%20suggest%20double%20checking%20the%20following%20points%3A%3C%2FP%3E%0A%3CP%3E1%EF%BC%9ASet%20the%20NVIC%20priorities%20and%20try%20to%20assign%20a%20higher%20priority%20to%20CTIMER0%20than%20DMA%20and%20ADC%2C%20then%20test%20again.%3C%2FP%3E%0A%3CP%3E2%EF%BC%9AVerify%20that%20the%20transfer%20type%20is%20set%20to%20kDMA_PeripheralToMemory.%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mayliu1_0-1764831075550.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22mayliu1_0-1764831075550.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22mayliu1_0-1764831075550.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22mayliu1_0-1764831075550.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22mayliu1_0-1764831075550.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22mayliu1_0-1764831075550.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F368552i042D29DD200F8EBA%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22mayliu1_0-1764831075550.png%22%20alt%3D%22mayliu1_0-1764831075550.png%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3Emayliu1_0-1764831075550.png%3C%2Fspan%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EBest%20Regards%3C%2FP%3E%0A%3CP%3EMayLiu%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2255027%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20RT685%20CTimer0%20callBack%20delayed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2255027%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E1)%20Setting%20the%20priority%20solves%20the%20problem.%20But%20I%20don't%20understand%20why%20it's%20necessary.%20In%20theory%2C%20the%20hardware%20has%20all%20the%20time%20it%20needs%20to%20handle%20the%20DMA%20callback.%3CBR%20%2F%3E2)%20I've%20tried%20many%20times%2C%20but%20if%20I%20switch%20to%20PeripheralToMemory%2C%20strange%20things%20happen%20and%20nothing%20works.%20The%20ADC%20still%20remain%20in%20interrupt%20and%20DMA%20never%20calls%20the%20callback.%20Maybe%20PeripheralToMemory%20don't%20handle%20correctly%20the%20watermark%20set%20to%2015%3F%20Could%20using%20DMA%20in%20MemoryToMemory%20be%20a%20problem%3F%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20in%20advance.%3CBR%20%2F%3ERegards.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2256091%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20RT685%20CTimer0%20callBack%20delayed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2256091%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F256644%22%20target%3D%22_blank%22%3E%40katte82%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EThanks%20for%20your%20updated%20information.%3C%2FP%3E%0A%3CP%3EA1%3A%20It%20is%20necessary%2C%20because%20the%20callback%20runs%20in%20the%20interrupt%20service%20routine%20(ISR)%2C%26nbsp%3B%20and%20NVIC%20priority%20decides%20who%20runs%20first.%26nbsp%3BDMA%2FADC%20ISR%20preempted%20CTIMER0%2C%20so%20the%20CTIMER0%20callback%20was%20delayed.%3C%2FP%3E%0A%3CP%3EA2%3A%20I%20suggest%20you%20can%20refer%20to%20SDK%20demo%20%22evkmimxrt685_lpadc_dma_cm33%22%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EBest%20Regards%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EMayLiu%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2258844%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20RT685%20CTimer0%20callBack%20delayed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2258844%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EThanks%20for%20the%20hint.%3CBR%20%2F%3E1)%20I%20continue%20not%20understand%20why%20the%20ctimer%20interrupt%20need%20a%20greater%20priority.%20There%20are%20many%20%22free%20usec%22%20after%20DMA%20callback.%3CBR%20%2F%3E%3CBR%20%2F%3E2)%20In%20example%2C%20the%20data%20flow%20is%20handled%20by%20the%20software.%3CBR%20%2F%3EI'm%20trying%20to%20configure%20the%20cpu%20to%20do%20all%20the%20hard%20work%20by%20itself.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20and%20Best%20regards.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2259801%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20RT685%20CTimer0%20callBack%20delayed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2259801%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20think%20if%20the%20%3CSPAN%3Ectimer%26nbsp%3B%3C%2FSPAN%3Ehas%20a%20lower%20priority%2C%20its%20execution%20could%20be%20delayed%2C%20affecting%20timing%20precision%20and%20real%20time%20performance.%3C%2FP%3E%3C%2FLINGO-BODY%3E