MCXA346 3路ADC同步采集的问题

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

MCXA346 3路ADC同步采集的问题

Jump to solution
567 Views
346500452
Contributor III

你好

我看了数据手册MCXA有4个ADC,然后手册上写ADC0可以触发所有的ADC采集再同一时刻。

所有我在frdmmcxa346_lpadc_trigger_exception例程的基础上,加上了Ctimer0的MR1,0.5ms周期性触发ADC采集,每个ADC配置的采集1个通道。

现在的问题是只能进入ADC0的中断(是按照定时器周期触发的),ADC1和ADC2中断进不去。

这个同步采集,是这样用的吗?难道是我理解错了吗?

我把我的工程附在附件里了。

Labels (1)
0 Kudos
Reply
1 Solution
515 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @346500452 

I have reviewed your code. Please make the following changes and then test:

  1. Enable hardware trigger for ADC2.
  2. Configure ADC1 and ADC2 to also use Trigger Control Register 0. In the INPUTMUX, route to ADC1_TRIG0 and ADC2_TRIG0.
Alice_Yang_0-1767845363629.png

 

Alice_Yang_1-1767845368287.png

 

If it still does not work, disable ADC0 and ADC2, and check whether ADC1 works correctly.

Thank you.

 

BR

Alice

View solution in original post

0 Kudos
Reply
3 Replies
516 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @346500452 

I have reviewed your code. Please make the following changes and then test:

  1. Enable hardware trigger for ADC2.
  2. Configure ADC1 and ADC2 to also use Trigger Control Register 0. In the INPUTMUX, route to ADC1_TRIG0 and ADC2_TRIG0.
Alice_Yang_0-1767845363629.png

 

Alice_Yang_1-1767845368287.png

 

If it still does not work, disable ADC0 and ADC2, and check whether ADC1 works correctly.

Thank you.

 

BR

Alice

0 Kudos
Reply
453 Views
346500452
Contributor III

你好,爱丽丝

    谢谢。我已经解决了上述的问题。

    需要补充的一点是,在debug的时候,需要开启overflow中断,并rst FIFO,否则会在debug暂停的时候产生overflow,而且ADC会自动停止。全速运行时不会存在这个问题。

    if (status & kLPADC_ResultFIFO0OverflowFlag)
    {
        LPADC_ClearStatusFlags(ADC0, kLPADC_ResultFIFO0OverflowFlag);
        LPADC_DoResetFIFO(ADC0);
    }

 

下一步,我打算加上DMA来搬运ADC完成采集的数据,我现在是用的3路ADC,是需要用DMA的3个通道来搬运吗,有其他更好的方法吗?

   

谢谢

0 Kudos
Reply
445 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @346500452 

是的,需要3个通道DMA来搬运。因为您使用的是3个ADC并发,每个ADC需要各自的DMA通道。

 

BR

Alice

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2289203%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3EMCXA346%20Synchronized%20Acquisition%20of%203%20ADCs%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2289203%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3EHow%20are%20you%3F%3C%2FP%3E%3CP%3EI%20read%20the%20datasheet%20MCXA%20has%204%20ADCs%20and%20then%20the%20manual%20says%20ADC0%20can%20trigger%20all%20ADCs%20to%20acquire%20again%20at%20the%20same%20moment.%3C%2FP%3E%3CP%3EAll%20I%20added%20to%20the%20frdmmcxa346_lpadc_trigger_exception%20routine%20is%20MR1%20for%20Ctimer0%2C%200.5ms%20periodic%20triggering%20of%20ADC%20acquisitions%2C%201%20channel%20per%20ADC%20configured%20for%20acquisition.%3C%2FP%3E%3CP%3EThe%20problem%20now%20is%20that%20you%20can%20only%20access%20ADC0%20interrupts%20(which%20are%20triggered%20according%20to%20the%20timer%20cycle)%2C%20and%20ADC1%20and%20ADC2%20interrupts%20don't%20go%20in.%3C%2FP%3E%3CP%3EThis%20synchronized%20capture%2C%20is%20that%20how%20it%20works%3F%20Am%20I%20misunderstanding%20it%3F%3C%2FP%3E%3CP%3EI've%20attached%20my%20project%20as%20an%20attachment.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2289203%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EMCXA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2289836%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MCXA346%203%E8%B7%AFADC%E5%90%8C%E6%AD%A5%E9%87%87%E9%9B%86%E7%9A%84%E9%97%AE%E9%A2%98%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2289836%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F179561%22%20target%3D%22_blank%22%3E%40346500452%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CP%3EI%20have%20reviewed%20your%20code.%20Please%20make%20the%20following%20changes%20and%20then%20test%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EEnable%20hardware%20trigger%20for%20ADC2.%3C%2FLI%3E%0A%3CLI%3EConfigure%20ADC1%20and%20ADC2%20to%20also%20use%20Trigger%20Control%20Register%200.%20In%20the%20INPUTMUX%2C%20route%20to%20ADC1_TRIG0%20and%20ADC2_TRIG0.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Alice_Yang_0-1767845363629.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Alice_Yang_0-1767845363629.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Alice_Yang_0-1767845363629.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Alice_Yang_0-1767845363629.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F372072i3B7670DD462D12BC%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Alice_Yang_0-1767845363629.png%22%20alt%3D%22Alice_Yang_0-1767845363629.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%0A%3CBR%20%2F%3E%0A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Alice_Yang_1-1767845368287.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Alice_Yang_1-1767845368287.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Alice_Yang_1-1767845368287.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Alice_Yang_1-1767845368287.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F372073i88D7AD99DCD7A5A2%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Alice_Yang_1-1767845368287.png%22%20alt%3D%22Alice_Yang_1-1767845368287.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%0A%3CBR%20%2F%3E%0A%3CP%3EIf%20it%20still%20does%20not%20work%2C%20disable%20ADC0%20and%20ADC2%2C%20and%20check%20whether%20ADC1%20works%20correctly.%3C%2FP%3E%0A%3CP%3EThank%20you.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EAlice%3C%2FP%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2290562%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MCXA346%203%E8%B7%AFADC%E5%90%8C%E6%AD%A5%E9%87%87%E9%9B%86%E7%9A%84%E9%97%AE%E9%A2%98%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2290562%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%20Alice.%3C%2FP%3E%3CP%3E%20%20%20%20Thanks.%20I%20have%20solved%20the%20above%20problem.%3C%2FP%3E%3CP%3E%20%20%20%20One%20thing%20to%20add%20is%20that%20when%20debugging%2C%20you%20need%20to%20turn%20on%20the%20overflow%20interrupt%20and%20rst%20FIFO%2C%20otherwise%20it%20will%20generate%20overflow%20when%20debug%20pauses%20and%20the%20ADC%20will%20stop%20automatically.%20This%20problem%20does%20not%20exist%20when%20running%20at%20full%20speed.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%20translate%3D%22no%22%3E%20%20%20%20if%20(status%20%26amp%3B%20kLPADC_ResultFIFO0OverflowFlag)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20LPADC_ClearStatusFlags(ADC0%2C%20kLPADC_ResultFIFO0OverflowFlag)%3B%0A%20%20%20%20%20%20%20%20LPADC_DoResetFIFO(ADC0)%3B%0A%20%20%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CDIV%3E%3CDIV%3E%3CBR%20%2F%3E%3CP%3ENext%2C%20I'm%20going%20to%20add%20DMA%20to%20carry%20the%20data%20that%20the%20ADC%20finishes%20capturing%2C%20I'm%20using%20a%203-way%20ADC%2C%20do%20I%20need%20to%20use%20the%203%20channels%20of%20the%20DMA%20to%20carry%20it%2C%20is%20there%20any%20other%20better%20way%3F%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%3CP%3Ethank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2290666%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MCXA346%203%E8%B7%AFADC%E5%90%8C%E6%AD%A5%E9%87%87%E9%9B%86%E7%9A%84%E9%97%AE%E9%A2%98%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2290666%22%20slang%3D%22zh-CN%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F179561%22%20target%3D%22_blank%22%3E%40346500452%3C%2FA%3E%20%3C%2FP%3E%0A%3CP%3EYes%2C%203%20channels%20of%20DMA%20are%20needed%20to%20carry%20it.%20Since%20you%20are%20using%203%20ADCs%20concurrently%2C%20each%20ADC%20needs%20its%20own%20DMA%20channel.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EAlice.%3C%2FP%3E%3C%2FLINGO-BODY%3E