frdmmcxe31b_emios_input_capture kEMIOS_PEC_Continuous

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

frdmmcxe31b_emios_input_capture kEMIOS_PEC_Continuous

1,090 Views
hyf_grass
Contributor I

I am working with the FRDM-MCXE31B development board, and I want to modify the frdmmcxe31b_emios_input_capture example program to enable the continuous counting mode for eMIOS. I have made the modifications as follows,
EMIOS_GetDefaultConfig(&emiosConfig);

emiosConfig.prescale = EXAMPLE_EMIOS_CLK_FREQ / EXAMPLE_COUNTERBUS_FREQ - 1U;
emiosConfig.useGlobalTimeBase = true;
EMIOS_Init(EXAMPLE_EMIOS, &emiosConfig);

ucMCConfig.period = 0xFFFFU;
ucMCConfig.prescale = 0U;
ucMCConfig.ucMode = kEMIOS_MC_UpCount;
ucMCConfig.clockSource = kEMIOS_ClkSrcInternal;
ucMCConfig.prescalerSource = kEMIOS_Prescaler_PrescaledClock;
ucMCConfig.counterResetTiming = kEMIOS_ResetMatchEnd;
ucMCConfig.reloadOutputDelay = 0U;
ucMCConfig.enableFreeze = false;
EMIOS_ConfigModulusCounter(EXAMPLE_EMIOS, &ucMCConfig, EXAMPLE_COUNTERBUS_CHANNEL);

ucICConfig.ucMode = kEMIOS_PEC_Continuous;//kEMIOS_IPWM;
ucICConfig.counterBus = kEMIOS_CounterBus_A;
ucICConfig.edgePolarity = kEMIOS_IC_RisingEdge;
ucICConfig.filterClock = kEMIOS_Filter_PrescaledClock;
ucICConfig.filterWidth = kEMIOS_Filter_16_Cycle;
ucICConfig.enableFreeze = false;
ucICConfig.startTime = 0x90;
ucICConfig.endTime = 0x800;
EMIOS_ConfigInputCapture(EXAMPLE_EMIOS, &ucICConfig, EXAMPLE_IC_CHANNEL);

// EMIOS_EnableUCInterrupt(EXAMPLE_EMIOS, EXAMPLE_IC_CHANNEL);
// (void)EnableIRQ(EXAMPLE_EMIOS_IRQn);

EMIOS_EnableUCPrescaler(EXAMPLE_EMIOS, EXAMPLE_COUNTERBUS_CHANNEL);
EMIOS_EnableUCPrescaler(EXAMPLE_EMIOS, EXAMPLE_IC_CHANNEL);
EMIOS_EnableGlobalPrescaler(EXAMPLE_EMIOS);
but I checked the relevant registers and found no changes at all. Could you please tell me how to configure it correctly, and which register I should read to get the counter value?

Labels (1)
0 Kudos
Reply
1 Reply

1,065 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @hyf_grass 

 

Based on your code, please try the following modifications:

  1. Delete the following two lines, or set both of them to 0:
    ucICConfig.startTime = 0x90;
    ucICConfig.endTime = 0x800;

  2. Make sure the CounterBus is enabled:
    ucMCConfig.ucMode = kEMIOS_MC_UpCount; // Up counter mode
    ucMCConfig.period = 0xFFFF; // Maximum counter value
    ucMCConfig.prescale = 0; // No prescaling, increases counting speed

  3. The pulse count value is read from register A, and you can use the SDK API:
    EMIOS_GetAn(EMIOS_Type *base, uint8_t channel)

 
 
 
BR
Alice 
 
 

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2344040%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Efrdmmcxe31b_emios_input_capture%20kEMIOS_PEC_Continuous%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2344040%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20am%20working%20with%20the%20FRDM-MCXE31B%20development%20board%2C%20and%20I%20want%20to%20modify%20the%20frdmmcxe31b_emios_input_capture%20example%20program%20to%20enable%20the%20continuous%20counting%20mode%20for%20eMIOS.%20I%20have%20made%20the%20modifications%20as%20follows%2C%3CBR%20%2F%3EEMIOS_GetDefaultConfig(%26amp%3BemiosConfig)%3B%3C%2FP%3E%3CP%3EemiosConfig.prescale%20%3D%20EXAMPLE_EMIOS_CLK_FREQ%20%2F%20EXAMPLE_COUNTERBUS_FREQ%20-%201U%3B%3CBR%20%2F%3EemiosConfig.useGlobalTimeBase%20%3D%20true%3B%3CBR%20%2F%3EEMIOS_Init(EXAMPLE_EMIOS%2C%20%26amp%3BemiosConfig)%3B%3C%2FP%3E%3CP%3EucMCConfig.period%20%3D%200xFFFFU%3B%3CBR%20%2F%3EucMCConfig.prescale%20%3D%200U%3B%3CBR%20%2F%3EucMCConfig.ucMode%20%3D%20kEMIOS_MC_UpCount%3B%3CBR%20%2F%3EucMCConfig.clockSource%20%3D%20kEMIOS_ClkSrcInternal%3B%3CBR%20%2F%3EucMCConfig.prescalerSource%20%3D%20kEMIOS_Prescaler_PrescaledClock%3B%3CBR%20%2F%3EucMCConfig.counterResetTiming%20%3D%20kEMIOS_ResetMatchEnd%3B%3CBR%20%2F%3EucMCConfig.reloadOutputDelay%20%3D%200U%3B%3CBR%20%2F%3EucMCConfig.enableFreeze%20%3D%20false%3B%3CBR%20%2F%3EEMIOS_ConfigModulusCounter(EXAMPLE_EMIOS%2C%20%26amp%3BucMCConfig%2C%20EXAMPLE_COUNTERBUS_CHANNEL)%3B%3C%2FP%3E%3CP%3EucICConfig.ucMode%20%3D%20kEMIOS_PEC_Continuous%3B%2F%2FkEMIOS_IPWM%3B%3CBR%20%2F%3EucICConfig.counterBus%20%3D%20kEMIOS_CounterBus_A%3B%3CBR%20%2F%3EucICConfig.edgePolarity%20%3D%20kEMIOS_IC_RisingEdge%3B%3CBR%20%2F%3EucICConfig.filterClock%20%3D%20kEMIOS_Filter_PrescaledClock%3B%3CBR%20%2F%3EucICConfig.filterWidth%20%3D%20kEMIOS_Filter_16_Cycle%3B%3CBR%20%2F%3EucICConfig.enableFreeze%20%3D%20false%3B%3CBR%20%2F%3EucICConfig.startTime%20%3D%200x90%3B%3CBR%20%2F%3EucICConfig.endTime%20%3D%200x800%3B%3CBR%20%2F%3EEMIOS_ConfigInputCapture(EXAMPLE_EMIOS%2C%20%26amp%3BucICConfig%2C%20EXAMPLE_IC_CHANNEL)%3B%3C%2FP%3E%3CP%3E%2F%2F%20EMIOS_EnableUCInterrupt(EXAMPLE_EMIOS%2C%20EXAMPLE_IC_CHANNEL)%3B%3CBR%20%2F%3E%2F%2F%20(void)EnableIRQ(EXAMPLE_EMIOS_IRQn)%3B%3C%2FP%3E%3CP%3EEMIOS_EnableUCPrescaler(EXAMPLE_EMIOS%2C%20EXAMPLE_COUNTERBUS_CHANNEL)%3B%3CBR%20%2F%3EEMIOS_EnableUCPrescaler(EXAMPLE_EMIOS%2C%20EXAMPLE_IC_CHANNEL)%3B%3CBR%20%2F%3EEMIOS_EnableGlobalPrescaler(EXAMPLE_EMIOS)%3B%3CBR%20%2F%3Ebut%20I%20checked%20the%20relevant%20registers%20and%20found%20no%20changes%20at%20all.%20Could%20you%20please%20tell%20me%20how%20to%20configure%20it%20correctly%2C%20and%20which%20register%20I%20should%20read%20to%20get%20the%20counter%20value%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2344040%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EMCXC%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2344529%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20frdmmcxe31b_emios_input_capture%20kEMIOS_PEC_Continuous%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2344529%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%2F231665%22%20target%3D%22_blank%22%3E%40hyf_grass%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CP%3EBased%20on%20your%20code%2C%20please%20try%20the%20following%20modifications%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%0A%3CP%3EDelete%20the%20following%20two%20lines%2C%20or%20set%20both%20of%20them%20to%200%3A%3CBR%20%2F%3EucICConfig.startTime%20%3D%200x90%3B%3CBR%20%2F%3EucICConfig.endTime%20%3D%200x800%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%0A%3CP%3EMake%20sure%20the%20CounterBus%20is%20enabled%3A%3CBR%20%2F%3EucMCConfig.ucMode%20%3D%20kEMIOS_MC_UpCount%3B%20%2F%2F%20Up%20counter%20mode%3CBR%20%2F%3EucMCConfig.period%20%3D%200xFFFF%3B%20%2F%2F%20Maximum%20counter%20value%3CBR%20%2F%3EucMCConfig.prescale%20%3D%200%3B%20%2F%2F%20No%20prescaling%2C%20increases%20counting%20speed%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%0A%3CP%3EThe%20pulse%20count%20value%20is%20read%20from%20register%20A%2C%20and%20you%20can%20use%20the%20SDK%20API%3A%3CBR%20%2F%3EEMIOS_GetAn(EMIOS_Type%20*base%2C%20uint8_t%20channel)%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EBR%3C%2FDIV%3E%0A%3CDIV%3EAlice%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E