Skip to main content
CSeif.2
Associate II
September 21, 2021
Question

Setup eMIOS UC for IPWM

  • September 21, 2021
  • 1 reply
  • 1354 views

Hello Erwan,

thank you very much for the answers and the insight in the other thread.

Decided to start another thread, due to different topic here.

I tried to at least make the IPWM input work on eMIOS0 Ch 2 and created a little example project with channel 0 PWM output externally linked to the channel 2 input.

My new questions:

  • With eMIOS 0 global prescaler at 20, resulting in internal counter frequency of 1,000,000 (Hz?), the ICU prescaler at 1 gives 1,000,000 (Hz?), is there any way to increase ICU count speed by a factor of 10 to get decimal point of PWM "percentage"?
  • Is there any tool or table with recommended prescaler ratios between PWM and ICU?

In the attached patch.xml I reworked the icu_lld.c component implementation of the flag interrupt routine according to the reference manuals information.

0693W00000F9tWkQAJ.pngI setup the eMIOS channel with EMIOS_CCR_MODE_IPWM flag in icu_lld_start function.

Below you see the changed part of the icu_lld_serve_interrupt function:

if ((sr & EMIOSS_FLAG) != 0U) {
 icup->emiosp->CH[icup->emios_ch].S.R |= EMIOSS_FLAGC;
 if (icup->config->mode == ICU_INPUT_ACTIVE_HIGH) {
 	 if(icup->emiosp->CH[icup->emios_ch].C.R & EMIOS_CCR_MODE_IPWM && \
 			 (icup->config->width_cb != NULL)){
 		 icup->pe.a2_2 = (int16_t)icup->emiosp->CH[icup->emios_ch].A.R;
 		 icup->pe.a2_1 = (int16_t)icup->emiosp->CH[icup->emios_ch].B.R;
 		 width = (icup->pe.a2_2 - icup->pe.a2_1);
 		 icup->width = (uint16_t)(width);
 		 icup->config->width_cb(icup);
 	 }
 }
....
}

  • Substracting B1 from A2 as written on the page before gives me 50 (50% PWM) or 20 (20% PWM)
  • How to get 500 instead of 50 to have a little more resolution?

Maybe somebody had the same problems while getting IPWM to work. Hope my code helps a bit.

@Mods: Please delete my last reply in How to setup IPWM on channels UC13, UC14 and UC15 with Low Level Driver component? thread, because I cannot do it myself. Thank you.

Best regards,

Christopher Seifert

    This topic has been closed for replies.

    1 reply

    Erwan YVIN
    ST Employee
    September 29, 2021

    Thank you very much for your analysis ,

    i am checking with experts.

    and i have created a Change request in order tol add IPWN configuration in our configuration.

    we will come back to you ;)

    Best Regards

    Erwan