Jump to content
Electronics-Lab.com Community

How to Output PWM Square Waves on OK1028A-C Development Board?


Recommended Posts

After checking the schematic of the OK1028A-C and the "QorIQ LS1028 AReference Manual", it is found that there are 8 FlexTimers (FTM) available by defaultLS1028on the board, with each FTM having 8 pwm channels.

How to Output PWM Square Waves on OK1028A-C Development Board?

The default backlight uses the pwm generated by FTM1, and we use FTM7 to do the pwm test.

As shown in the figure below:

How to Output PWM Square Waves on OK1028A-C Development Board?

LS1028 RCWSR12 registers 12-14 are pin multiplexed for I2C4.

As shown in the figure below:

How to Output PWM Square Waves on OK1028A-C Development Board?

The I2C4 pin can be multiplexed into six pin functions. The OK1028A-C sets the pins to rx and tx of can2 , you can see T6_CAN2_RX, U7_CAN2_TX in the schematic "OK1028A-C_V1.1".

We can set I2C4 to the pwm pin by modifying the rcw file.

OK1028A-C supports the pwm function by default, so we do not need to transplant the driver. All we need to do is to modify the pinmux and add the corresponding device node of pwm in the device tree. Modify packages/firmware

In the /rcw/ls1028ardb/RSQPP0x85bb/rcw1500gpu600.rcw file, the setting for IIC4_PMUX is to configure the pin as a pwm output.

Change IIC4 _ PMUX = 2 to IIC4 _ PMUX = 4

As shown in the figure below:

How to Output PWM Square Waves on OK1028A-C Development Board?

After completing the above settings, we need to modify the device tree code and add pwm configuration. The path of our modified file is as follows:

packages/linux/linux/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi.

Then add the pwm7 device

Pwm7: pwm@2860000 {
                        compatible = "fsl,ls1028a-ftm-pwm";
                        reg =;
                        #pwm-cells =;
                        clock-names = "ftm_sys";
                        clocks = <&ftm_sysclk>;
                };

As shown in the figure below:

How to Output PWM Square Waves on OK1028A-C Development Board?

▐   Start the OK1028A-C system

 

root@forlinx:~#cat /sys/kernel/debug/pwm View our current pwm devices

As shown in the figure below:

How to Output PWM Square Waves on OK1028A-C Development Board?

We have now opened a pwm controller and can see that FTM1 supports 8 channels, with the backlight using pwm channel 1. Compile the modified device tree file and firmware, burn them intoFolinx EmbeddedLS1028A-CDevelopment Board, and boot up the system.

root@forlinx:~#cat /sys/kernel/debug/pwm View our current pwm devices.

As shown in the figure below:

How to Output PWM Square Waves on OK1028A-C Development Board?

At this time, although the pwm device we added is turned on, it is still different from the pwm0 device. Each channel of the newly added pwm device has no set period and duty cycle.

So in the next step, we do not need to add driver code, but use sys to set pwm parameters directly. Pwmchip8 is the pwm device we added.

How to Output PWM Square Waves on OK1028A-C Development Board?

▐  Enable pwm channel used

root@forlinx:~#echo 1 > /sys/class/pwm/pwmchip8/export Initialize pwm channel 1

root@forlinx:~#echo 2 > /sys/class/pwm/pwmchip8/export Initialize pwm channel 2

root@forlinx:~#cat /sys/kernel/debug/pwm CommandCheck out our current pwm devices:

How to Output PWM Square Waves on OK1028A-C Development Board?

If you want to cancel the corresponding pwm channel, you can use "echo 1 > /sys/class/pwm/pwmchip8/unexport".

“echo 2 > /sys/class/pwm/pwmchip8/unexport” command.

Since we can only enable pwm one way at a time, configure and turn on pwm1 first.

root@forlinx:~#echo 1000000 > /sys/class/pwm/pwmchip8/pwm1/period Configure the pwm1 period to be 1000000 in ns, which is 1kHZ.

root@forlinx:~#echo 500000 > /sys/class/pwm/pwmchip8/pwm1/duty_cycle Configure the duty_cycle to 500000, the on time in a cycle is the duty cycle, the unit is ns, and the duty cycle is 50%.

root@forlinx:~#echo 1 > /sys/class/pwm/pwmchip8/pwm1/enable Enable

root@forlinx:~#cat/sys/class/pwm/pwmchip8/pwm1/{enable,period,duty_cycle}Command to view our pwm enable status, period, and duty cycle.

As shown in the figure below:

How to Output PWM Square Waves on OK1028A-C Development Board?

▐  Test the 1khz square wave generated by T6_CAN2_RX with oscilloscope

Since we can only enable one pwm at a time, we need to turn off pwm1 first if we want to enable pwm2.

root@forlinx:~#echo 0 > /sys/class/pwm/pwmchip8/pwm1/enable

root@forlinx:~#echo 1000000 > /sys/class/pwm/pwmchip8/pwm2/period Configure period to 1000000

root@forlinx:~#echo 500000 > /sys/class/pwm/pwmchip8/pwm2/duty_cycle Configure duty_cycle to 500000.

root@forlinx:~#echo 1 > /sys/class/pwm/pwmchip8/pwm2/enable Enable

root@forlinx:~#cat/sys/class/pwm/pwmchip8/pwm2/{enable,period,duty_cycle}

How to Output PWM Square Waves on OK1028A-C Development Board?

▐  Test the 1khz square wave generated by U7_CAN2_TX with oscilloscope

When we use OK1028A-C single board computer, due to pin multiplexing, the pins of many functional modules are not led out, but the driver of the module is supported. In this case, we only need to modify the corresponding pinmux configuration and device tree file of rcw to use the corresponding function.

Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...