pwm configuration in MKV46F256VLL16

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

pwm configuration in MKV46F256VLL16

Jump to solution
1,231 Views
soaring_sun
Contributor III

Hi,

I have been trying to configure PWM setting to give a constant duty of 50% on the MKV46F256VLL16 board. I have referred both the datasheet (and Trm) along with the example program, but I'm not able to relate one to another. I have the following doubts regarding that and I hope someone would clear the air for me.

1. Lets say I want to use PWMA. should the base address be mentioned in the code or is it present in a header which should be #include -ed in the main? If I have to do this manually, where do I find the address for the PWM? (In the example, it is done manually and I didn't understand from where the value was obtained.)

Capture.PNG

2.  In the following figure, the modules are changed, how will I be able to check the change in duty using an oscilloscope? Is the duty being applied to A0 and B0 alone (since they are configured in the complement mode)? If so, then what is the use of having different modules?

Capture.PNG

3. During the complementary pin setup, in the datasheet, it is said that PWMA and PWMB will complement each other. At this time, A0 complements B0, A1 complements B1 and so on... Is this true? Will I be able to change this settings manually? For example, A0 to complement B1?

4. There is a fault set up function used. What kind of faults can I be expecting at the PWM?

Capture.PNG

 

I will be looking forward for answers. Thank you.

PWM functionality in KV4x 

0 Kudos
1 Solution
1,173 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

You can increase the PWM resolution with the Nano-Edge feature, you can find more detailed information about it at this post: https://community.nxp.com/t5/Kinetis-Microcontrollers/Nano-edge-placement-feature-for-eFlexPWM-modul...

Let me know if this is helpful, if you have more questions do not hesitate to ask me.
Best regards,
Omar

View solution in original post

0 Kudos
6 Replies
1,184 Views
soaring_sun
Contributor III

Oh, yikes I had missed that out. Thank you,@nxf54944. It helps. But while we are still in the PWM topic, I would like to know if there is any chance I can get hold of a high resolution PWM.

From the SDK manual https://mcuxpresso.nxp.com/api_doc/dev/1500/a00043.html I see that there is no much resolution. If say, I want to have a 50.25% duty cycle, how will I be able to achieve it? 

Capture.PNG

I was wondering if I could give 50.25 in the function. But since it is of uint8_t type, I don't think it would allow a decimal to pass through. Is there any function I should be using for this? Or is there a different block that I should be configuring for this?

Capture.PNG

 

PS: If you have a detailed TRM which represents a few block diagrams for all units, please share it. It would be a lot helpful.

0 Kudos
1,174 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

You can increase the PWM resolution with the Nano-Edge feature, you can find more detailed information about it at this post: https://community.nxp.com/t5/Kinetis-Microcontrollers/Nano-edge-placement-feature-for-eFlexPWM-modul...

Let me know if this is helpful, if you have more questions do not hesitate to ask me.
Best regards,
Omar

0 Kudos
1,166 Views
soaring_sun
Contributor III

Thank you Omar, it helps

0 Kudos
1,213 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello soaring_sun

 

My name is Omar and I will gladly answer your questions:

1. The address of the module is defined in the header file, you don't need to declare it in the main. You can find the peripheral address in the reference manual at the peripheral memory map or in chapter 5.3 table 5-2. I do not suggest editing that header, it is already configured to access the registers of the device.

nxf54944_9-1612991802307.png

nxf54944_8-1612991760531.png

2. This kPWM_Module_x corresponds to the submodules of the peripheral, that function updates the duty cycle of the submodule, the modules are configured as a complementary channel where channel A generates the signal. Here you can see the pins that you can use to measure the signal:

nxf54944_7-1612991581295.png

3. Yes, you can change the settings to B complements A or leave the channels independent but one channel cannot complement another channel. This can be configured in the field "pairOperation" of the variable "pwmConfig"

 

4. When fault protection hardware disables PWM outputs, the PWM generator continues to run, only the output pins are forced to logic 0, logic 1, or tristated depending on the values of OCTRL[PWMxFS].
You can find more detailed information about the fault in the reference manual from chapter 37.5.2.1.

 

Let me know if this is helpful, if you have more questions do not hesitate to ask me.
Best regards,
Omar

 

 

 

 

 

0 Kudos
1,203 Views
soaring_sun
Contributor III

Hi, Omar

Thank you for the answers, they were really helpful. But I still have a few more doubts regarding the same.

I didn't find the address already present in the header file for a project that was manually created. I referred the datasheet as you suggested and had to define them. But since you said, the address are defined in the header file, can you state which header I should be #include-ing?

Let's say I want to use PWM-B1 alone without having to use PWM-A1 pin (since A1 is in GPIO configuration). And I have set the setting to be acting in the independent mode. Then during the PWM setup, should I be using 1 or 2 in number of channels module? When I'm using PWM-B1, will the base address still remain PWMA?

Capture.PNG

0 Kudos
1,188 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello

The address of the peripheral is located at the file MKV46F16.h. When you create a project through the wizard and the SDK this file is added to your files so you don't need to include it.
These macros are to access the peripheral registers.

To use only one channel you need to put 1 in the number of channels module.
Yes, that first parameter is the PWM peripheral base address used to access the module registers.

If you have more questions do not hesitate to ask me.
Best regards,
Omar

0 Kudos