大家好,我想分享我的经验,关于ADCHS驱动程序和谐的PIC32 MK。这是我的配置是:1。PIC32 MK1024GPE
开发板2。MPLABX IDE 4.103。MPLAB和谐2.05.014。MPLABX C32 2.05i试图在Advices应用程序和和睦外围库中设置示例,但是,它不像我预期的那么好。这是我在这个问题上花了2个星期所观察到的。1。实例1:同时采样和转换类ADCHS,我发现最多ADCHs采样在同一时间只有6个通道中的5个。我不知道这是否是MCU的规格,因为我在他们的文档中没有注意到。触发器来自中断TMR3。而且,在GualLoalActudieT触发器上也可能是同一个问题。我的例子是打开ADC实例通道0到通道5,并选择PIN AN0到AN5作为每个实例通道的模拟捕获输入。理想情况下,所有模拟输入(AN0至AN5)应该同时捕获每个中断触发器。然而,只有通道5或AN5不能更新采样。然后,我检查是否只有AN5采样,它正在工作。我得出结论,只有5个模拟输入可以在一级同时捕获。请让我知道,如果你有任何想法,为什么我不能同时捕获所有6个模拟输入类1。我将继续在Clase2和Clase3. [代码] /*中,如果没有启用单独的中断,则所有数据中断都在这个ISR*/Value ySISR(O-AdcVixValue,IPL3AUTO)中进行处理(i=0;i<50;i++){if(true=DrvayAdcCl SPLPLESE(i)){APDD)。{AdCySAMPLESeRead(i);} } /*If(true=DrvAdAcCl SAMPLESS可用(0)){AppDATa. ADCBUFF(0)=DrvIAdCySAMPLESeRead(0);}(true=DRVAI ADCX SAMPLESS可用(1)){AppDATAYXAX= DRVYAADCYSAMPLESESRADE(1);}(true=DRVYAADCX SAMPLES可用(2)){AppDATA.ZAXIS=DRVY-ADCYSAMPLESESRID(2);阿特巴布}(true=DrvAdAcCySAMPLESE可用(3)){AppDATA=DrVyAdCySAMPLESeRead(3);}(真值=DrvAdAcCl SAMPLESS可用(4)){AppDATA
timeMistor=DrvAAdCySAMPLESESRADE(4);}(true=DRVYADCX采样可用(5)){AppDATA TimeMistor=DRVY-ADCCI SAMPLESREST(5);}(true=DrvayAdCl SAMPPLESA)可赋值(34)//IF(PLBIAdAdSypRealPoDATADSIAdEDIT(DRVAI ADCKIDID1,ADCHSYAN34));{AppDATA=DrvAADCYSAMPLESESRADE(34);//AppDATA;TimeMistor=PLBIAdAdSsSuffin PrutsReultGET(DrvayAdcTyId1,AdChsHAN34);}(true=DrvAADCl SAMPLES可用(6)){AppDATA TimeMistor=DRVYADCYSAMPLESESRADE(6);如果(true=DrvAADCYSAMPLIES可用(7)){AppDATA.TunSimult= DrvyAdCySAMPLESESRADE(7);}*/AppDATA DATAARADY=TRUE;/*清空ADC中断标志INTHOSTESTYADADCY1*/PLBIIN INTIOSSORCESTFLAGLISH(INTIOIDIO0,INSTORESCELADADCY1);}空AppOffice(空隙){int ADCL缓冲区;/*检查应用程序CurrENT状态。*/Lwitter(AppDATa.状态){/*应用程序的初始状态。*//AppHythEngInIt:{BoopAppRealsial= TRUE;IF(AppRealDistar){DrvayAdcIX初始化());/*PLIB AdChsSypRealStudioSCANSTUSET(DRVAI ADCXIDID1,ADCHSSYAN12,AdSSSX TraceGeRelosivEI EDGE,//AdsSSyScReang-TrigGeSoReCythTMR3A匹配AdSSStReGeReSuthCuxGualLaSaleApple RealEdk;*/DRVIAADC0OPEN();(DRVIAADC3OPEN);DRVYADADC5OPEN();//DRVYADADC6OPEN();/DRVYADADC6启动();AppDATA状态=APPYSTATEXServices任务;}中断;} AppHytStEnService任务:{if(true=AppDATA .DATAARDY){DrvAADCYSUTE());DRVI ADC1OPENSe;//AppDATA状态= APPYSTATEIGIN;DRVIAADCYSTATE();} //启用全局软件触发器/PLBIADADCHSGlobal Studio软件TrimeGrand(DRVAI ADCKIDID1);/ /等待转换完成AN0//()!PLBIAdAdSSyApple的DATA DATAISEDE(DRVAI ADCKIDID1,ADCHSYAN0);//ADCYBuffel= PLBIAdAdSsSuffiRePultReultGET(DRVA ADCKIDID1,ADCHSYAN0);/ /等待AN1///时转换完成(!)PLBIAADCHSSYAPLANDPATDATAISEDE(MyAdAdsScript实例,ADCHSYAN1);//结果[ 1 ]=PLBIAdAdSsSuffiRePultReultGET(MyAdAdsSh实例,ADCHSYAN1);/ /等待AN2///时转换完成()!PLIPHADCHSSYAPLANDPATDATAISEDE(MyAdAdsScript实例,ADCHSYAN2);//结果[ 2 ]=PLBIAdAdSsSuffiRePultReultGET(MyasAdsScript实例,ADCHSYAN2);//()DrviAdCySAMPLESeAsvices(0);//ADCYBuffel= DRVYADCDSAMPLESESRADE(0);Sturn:}/*toDO:实现应用程序状态机。*//*不应该执行默认状态。* /默认值:{/*todo:处理应用程序状态机中的错误。* /中断;} } [代码]
以上来自于百度翻译
以下为原文
Hi all,
I would like to share my experience of the issue on ADCHS Driver in H
ARMony for PIC32MK.
This is what my configure are:
1. PIC32MK1024GPE Development Board
2. MPLABX IDE 4.10
3. MPLAB Harmony 2.05.01
4. MPLABX C32 2.05
I am trying to set ADCHS following the examples in Harmony apps and Harmony Peripheral Libraries.
But, it does not work well as I expect. This is what I have observed after spending 2 weeks in this issue.
1. Example1:Simultaneous Sampling and Conversion Class1 of ADCHS, I found that the most ADCHS sampling at the same times is only 5 of 6 channels. I don't know if this is the specification of the MCU, since I don't notice in their document. The trigger is from interrupt TMR3. And, it could be the same issue on GlobalSoftwareTrigger. My example is to open ADC Instance Channel 0 to Channel 5, and select pin AN0 to AN5 as the analog capture input for each instance channel. Ideally, all analog inputs (AN0 to AN5) should simultaneously capture every interrupt trigger. However, only channel 5 or AN5 cannot update the sampling. Then, I check if only AN5 sampling, it is working. I conclude that only 5 Analog inputs can do the capture at the same time in Class1. Please let me know if you have any idea why I cannot capture all 6 analog inputs class1 at the same time. I will continue the other examples on Class2 and Class3.
- /* If individual interrupts are not enabled, all data interrupts are handled in this ISR */
- void __ISR(_ADC_VECTOR, ipl3AUTO) _IntHandlerDrvAdcCommonData(void)
- {
- int i;
- for(i=0;i<50;i++)
- {
- if(true == DRV_ADC_SamplesAvailable(i))
- {
- appData.ADCBUFF[i] = DRV_ADC_SamplesRead(i);
- }
- }
- /*if(true == DRV_ADC_SamplesAvailable(0))
- {
- appData.ADCBUFF[0] = DRV_ADC_SamplesRead(0);
- }
- if(true == DRV_ADC_SamplesAvailable(1))
- {
- appData.yAxis = DRV_ADC_SamplesRead(1);
- }
- if(true == DRV_ADC_SamplesAvailable(2))
- {
- appData.zAxis = DRV_ADC_SamplesRead(2);
- }
- if(true == DRV_ADC_SamplesAvailable(3))
- {
- appData.tempSensor = DRV_ADC_SamplesRead(3);
- }
- if(true == DRV_ADC_SamplesAvailable(4))
- {
- appData.tempSensor = DRV_ADC_SamplesRead(4);
- }
- if(true == DRV_ADC_SamplesAvailable(5))
- {
- appData.tempSensor = DRV_ADC_SamplesRead(5);
- }
- if(true == DRV_ADC_SamplesAvailable(34))
- //if(PLIB_ADCHS_AnalogInputDataIsReady(DRV_ADC_ID_1, ADCHS_AN34));
- {
- appData.tempSensor = DRV_ADC_SamplesRead(34);
- //appData.tempSensor = PLIB_ADCHS_AnalogInputResultGet( DRV_ADC_ID_1, ADCHS_AN34 );
- }
- if(true == DRV_ADC_SamplesAvailable(6))
- {
- appData.tempSensor = DRV_ADC_SamplesRead(6);
- }
- if(true == DRV_ADC_SamplesAvailable(7))
- {
- appData.tempSensor = DRV_ADC_SamplesRead(7);
- }
- */
- appData.dataReady = true;
- /* Clear ADC Interrupt Flag of INT_SOURCE_ADC_1*/
- PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_ADC_1);
- }
- void APP_Tasks(void) {
- int ADC_Buffer;
- /* Check the application's current state. */
- switch (appData.state) {
- /* Application's initial state. */
- case APP_STATE_INIT:
- {
- bool appInitialized = true;
- if (appInitialized) {
- DRV_ADC_Initialize();
- /*PLIB_ADCHS_AnalogInputScanSetup(
- DRV_ADC_ID_1,
- ADCHS_AN12,
- ADCHS_SCAN_TRIGGER_SENSITIVE_EDGE,
- //ADCHS_SCAN_TRIGGER_SOURCE_TMR3_MATCH
- ADCHS_TRIGGER_SOURCE_GLOBAL_SOFTWARE_EDGE
- );*/
- DRV_ADC0_Open();
- DRV_ADC1_Open();
- DRV_ADC2_Open();
- DRV_ADC3_Open();
- DRV_ADC4_Open();
- DRV_ADC5_Open();
- //DRV_ADC6_Open();
- //DRV_ADC_Start();
- DRV_TMR0_Start();
- appData.state = APP_STATE_SERVICE_TASKS;
- }
- break;
- }
- case APP_STATE_SERVICE_TASKS:
- {
- if(true == appData.dataReady)
- {
- DRV_ADC_Stop();
- appData.dataReady = false;
- //appData.state = APP_STATE_INIT;
- DRV_ADC_Start();
- }
- /// Enable global software trigger
- //PLIB_ADCHS_GlobalSoftwareTriggerEnable( DRV_ADC_ID_1);
- // Wait for conversion complete for AN0
- //while(!PLIB_ADCHS_AnalogInputDataIsReady(DRV_ADC_ID_1, ADCHS_AN0));
- //ADC_Buffer = PLIB_ADCHS_AnalogInputResultGet( DRV_ADC_ID_1, ADCHS_AN0 );
- // Wait for conversion complete for AN1
- //while(!PLIB_ADCHS_AnalogInputDataIsReady(MY_ADCHS_INSTANCE, ADCHS_AN1));
- //result[1] = PLIB_ADCHS_AnalogInputResultGet( MY_ADCHS_INSTANCE, ADCHS_AN1 );
- // Wait for conversion complete for AN2
- //while(!PLIB_ADCHS_AnalogInputDataIsReady(MY_ADCHS_INSTANCE, ADCHS_AN2));
- //result[2] = PLIB_ADCHS_AnalogInputResultGet( MY_ADCHS_INSTANCE, ADCHS_AN2 );
- //while(!DRV_ADC_SamplesAvailable(0));
- //ADC_Buffer = DRV_ADC_SamplesRead(0);
- break;
- }
- /* TODO: implement your application state machine.*/
- /* The default state should never be executed. */
- default:
- {
- /* TODO: Handle error in application's state machine. */
- break;
- }
- }
- }
复制代码
0