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,099 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,074 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