FLEXPWM outputs

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

FLEXPWM outputs

Jump to solution
490 Views
burhanhagi
Contributor III

I need 5 different PWM outputs with adjustable different frequency and different duty cycle.

I am using IMXRT1176 and it has 4 PWM peripherals from PWM1 to PWM4.

I am using all physical ouptut pins of PWM2, PWM3 and PWM4 for another ICs.(for SDRAM and ENET connections.) 

So I have only PWM1 available for my task.

  • - FLEXPWM1_PWM0_A (N12 pin)

- FLEXPWM1_PWM0_B (R14 pin)

- FLEXPWM1_PWM1_A (R13 pin)

- FLEXPWM1_PWM1_B (P15 pin)

- FLEXPWM1_PWM2_B (P13 pin)

  • The above PWM1, I can adjust different output frequency and duty cycle separately for each except (R14 pin) and (P15 pin). 

 

  • For  (R14 pin) and (P15 pin), I can adjust different duty cycle but not adjust different frequency. Because both are connected to the same sub module of PWM1.

How can achieve to use 2 extra PWM ouptuts that I need with different freq and duty cycle? Thanks.

Labels (1)
0 Kudos
1 Solution
287 Views
MultipleMonomials
Contributor III

Another option here would be to route the signals from PWM2, 3, or 4 to other pins via the XBAR.  PWM signals can be routed through the XBAR via PWM register settings, see here for some more info.

View solution in original post

5 Replies
288 Views
MultipleMonomials
Contributor III

Another option here would be to route the signals from PWM2, 3, or 4 to other pins via the XBAR.  PWM signals can be routed through the XBAR via PWM register settings, see here for some more info.

165 Views
burhanhagi
Contributor III

@MultipleMonomials  thank you very much for sharing very valuable information with us. You are right.

By using XBARA peripheral, I can use 11 seperate PWMs with different frequency and different duty cycle adjustable each.

I am not sure why NXP support team not well guide me in a right way. 

I have tested it on my eval board imxrt1166 with adding following lines; I share with anyone who needs  more PWM outputs in addition to existing peripheral output pins pyhsically. With using XBARA, all FLEXPWM1-2-3-4 sub-module outputs can be directed/routed to XBARA physical output pins.

BOARD_PWM_BASEADDR->SM[3].TCTRL = PWM_TCTRL_PWAOT0(1) | PWM_TCTRL_PWBOT1(1); //FLEXPWM1_PWM3SUBMODULE_A //FLEXPWM1_PWM3SUBMODULE_B

XBARA_SetSignalsConnection(XBARA1, kXBARA1_InputFlexpwm1Pwm3OutTrig0, kXBARA1_OutputIomuxXbarInout18);

and add below lines to pin_mux.c files;

IOMUXC_GPR->GPR20 |= IOMUXC_GPR_GPR20_IOMUXC_XBAR_DIR_SEL_18(0x01);

IOMUXC_SetPinMux(IOMUXC_GPIO_AD_34_XBAR1_INOUT18, 0U); // FLEXPWM1_PWM3_A

0 Kudos
293 Views
burhanhagi
Contributor III

@Gavin_Jia Do you have any suggestion about the problem?

0 Kudos
426 Views
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @burhanhagi ,

Thanks for your interest in NXP MIMXRT series!

In this usage scenario, hardware resources are limited, so we can consider using FlexIO to generate PWM.  FlexIO is an on-chip peripheral available on NXP I.MXRT series. It is a highly configurable module capable of emulating a wide range of communication protocols, such as UART, I2C,SPI, and I2S. Users can also use FlexIO to generate PWM and PFM waveform.
The standalone peripheral module FlexIO is not used for replacement of the PWM and PFM generator, but as an additional peripheral module of the MCU. This module enable users to build their own peripheral directly in the microcontroller.

It is suggested to refer to this application note, as well as the flexio_pwm demo in the SDK:

Gavin_Jia_0-1714031595999.png

 

Best regards,
Gavin

 

0 Kudos
424 Views
burhanhagi
Contributor III

Hello @Gavin_Jia . I am working on FLEXIO, today . I viewed the "flexio_pwm" example in SDK. I applied it on my eval board to see its effect. I changed my previous two PWM pins to FLEXIO. See the below pls:

IOMUXC_SetPinMux(IOMUXC_GPIO_AD_00_FLEXIO2_D00, 0U); 

IOMUXC_SetPinMux(IOMUXC_GPIO_AD_02_FLEXIO2_D02, 0U); 

Later, I observed two signals on oscilloscope. I adjusted two pins as different freq and duty cycles as FLEXIO. My observation is as follows;

- When I set some freq values for my two pins, one of the signal is not set at programmed freq value, instead it produces different freq. Such as when I set freq to 13KHz, I see it on scope screen as 49KHz or something different. This is true for 15,10,12,18Khz. However when setting to 20Khz, it is set as correctly. So, some freq values are not programmed well. For another Flexio signal, it is always set to 50KHz and always correct during my observation.

- When I set only one of my signals, freq value is correctly programmed to 12,13,15,18,20,30Khz. No problem exists. Setting single pin works as expected. However, as I stated above, setting 2 pins yield unexpected results.Why?

- Lastly, whether setting single or both Flexio output pins; When I set freq value below 12Khz, the example in SDK, is not working because of below lines; 

#define FLEXIO_MAX_FREQUENCY (DEMO_FLEXIO_CLOCK_FREQUENCY / 2U)

#define FLEXIO_MIN_FREQUENCY (DEMO_FLEXIO_CLOCK_FREQUENCY / 512U)

Even though I changed FLEXIO_MIN_FREQUENCY as  DEMO_FLEXIO_CLOCK_FREQUENCY / 4096U value, I can not program freq value to flexio pins correctly. I tried that for only setting my single FLEXIO signal and both. However every time I saw the wrong freq setting on oscilloscope screen. Demo example and the .pdf link you sent, uses 48KHz pwm freq for only one output pin. I tried to change freq values lower than 12KHz, but it is not working as expected. Freq settings get wrong every time evn though I lowered FLEXIO_MIN_FREQUENCY macro.

- Is there any limitation with setting lower freq with using Flexio? Below 12Khz is possible? Such as 500Hz or 1Khz?

Wait your helps.Thanks 

0 Kudos