Create a PWM Signal using Flex Timers with TWR-K20D72M

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

Create a PWM Signal using Flex Timers with TWR-K20D72M

Jump to solution
3,580 Views
luissanchezguti
Contributor I

Hi!!

I have a problem using my PWM (PE component), I can't syncronize my extern signal with my PWM

I read the manual of reference and I found about FlexTimers, but I didn't found an example code about how to use Flextimers and how to syncronize with an extern signal.

I'm already lost!!!

If you have an example code, or adicional information  I'd thank you much!!

Regards!!

Tags (1)
1 Solution
1,305 Views
DavidS
NXP Employee
NXP Employee

Hi Dave,

UnZIP this example into your KSDK_1.1.0 root folder then import it into KDS.

FYI - I'm just using the KSDK as a place to put the example folder and the example does not use KSDK.  Just KDS + PE.

I tested it on TWR-K20D72M and used o-scope to monitor the PWM signal on PTC1 to see it updating and changing.

Regards,

David

View solution in original post

0 Kudos
15 Replies
1,303 Views
Petr_H
NXP Employee
NXP Employee

Hi,

unfortunately, such synchronization is not supported by the Processor Expert logical device drivers.

There is only a possible to configure it with Init_FTM component that can generated a complete initialization code for you including this feature (there is a Synchronization group in Properties).

Best regards

Petr Hradsky

Processor Expert Support Team

1,304 Views
luissanchez
Contributor II

Hi Peter!!

Thanks a lot for reply me!!

Do you have some examples using INIT_FTM component?

Regards

0 Kudos
1,304 Views
Petr_H
NXP Employee
NXP Employee

Hi,

I'm sorry, but currently I'm not aware of any example projects using this feature.

Best regards

Petr Hradsky

Processor Expert Support Team

0 Kudos
1,304 Views
dave408
Senior Contributor II

By any chance have there been any updates regarding PWM using FTM and KDS+PEx?  I tried to configure FTM myself but couldn't get PWM to work.  I caved and then created a new project based on PEx and used the Init_FTM component.  After 4 hours of reading docs and playing with different settings, I still can't get PWM to work.  The outputs just stay high.  I'll keep looking around, though.

0 Kudos
1,306 Views
DavidS
NXP Employee
NXP Employee

Hi Dave,

UnZIP this example into your KSDK_1.1.0 root folder then import it into KDS.

FYI - I'm just using the KSDK as a place to put the example folder and the example does not use KSDK.  Just KDS + PE.

I tested it on TWR-K20D72M and used o-scope to monitor the PWM signal on PTC1 to see it updating and changing.

Regards,

David

0 Kudos
1,303 Views
dave408
Senior Contributor II

David, I have to use MQX -- isn't using PWM_LDD not supported in this use case?

0 Kudos
1,305 Views
DavidS
NXP Employee
NXP Employee

Hi Dave,

From your initial post I didn't infer you wanted to use MQX as well so I went down the baremetal KDS+PE approach.

Since MQX_4.1.1 has KDS support, I looked into enabling PE support of the BSP.  I was able to stumble my way through that and pull in the PWM_LDD.

Then in my MQX application ( I started with the lwadc mqx/example), I added in the same code from the baremtal example above and was able to test and see using o-scope the PWM duty cycle changing on PTC1.

Now this approach is not 100% clean.  Each time I generate PE code in the BSP, I have to delete the Sources/main.c and Generted_Code/vectors.c files.

The BSP Properties settings were updated to use the "Processor Expert Configuration Debug Builder", added a C Compiler Preprocessor Define of "__vect_table=__VECTOR_TABLE_ROM_START".

I also had used PE to set the clocking, disable Flash Configuration, and disabled Startup and Linker code generation.

I'll have to find a bit of time to document my process but wanted to let you know it is possible to enable KDS PE in the MQX_4.1.1 BSP for the TWR-K20D72M and use PE to configure the PWM.

A starting point in the mean time is the attached BSP+lwadc KDS projects.

Regards,

David

0 Kudos
1,305 Views
dave408
Senior Contributor II

FYI, if I recall correctly, MQX 4.1.1 is not the same as the MQX in the KSDK, which I am using.  I'm using KDS 2.0 + KSDK 1.1 with MQX enabled.  I'm going to try to open your projects now to poke around.

0 Kudos
1,305 Views
DavidS
NXP Employee
NXP Employee

Hi David,

Correct that the MQX_4.1.1 is different from KSDK_1.1.0 that has MQX in it too.

MQX_4.1.1 (call it classic) has its own peripheral drivers to use.

KSDK_1.1.0 MQX is the same RTOS but the drivers are provided by KSDK.

For the devices supported in KSDK_1.1.0, you can stitch together a MQX application or you could use PE to generate the MQX or MQXLite code and tasks while using the PE to configure the various SDKS peripherals you want to use.

MFS/RTCS/USB are separate stacks within KSDK but in general the MFS and RTCS are tightly coupled to MQX.  The USB stack can be used with OS or baremetal.

Regards,

David

0 Kudos
1,305 Views
dave408
Senior Contributor II

Thanks, David for your efforts to put something together.  I was doing the same thing in parallel, hoping that in the end the code would be portable over to my MQX project.  I've got a lot of things in my head right now that I'm going to try to express in the post.  Hopefully, you'll be able to bring me some clarity.  :smileyhappy:

In my current test project, I'm not using PWM_LDD since it's not readily available;  I am using fsl_ftm instead.  This brings up a question / concern / complaint I have about the current state of development using KDS in general, and hopefully you can point me in the right direction.  In the Freescale development ecosystem, it looks like we have several software packages to work with.  At least in my case, the ones of interest include:

  • KDS
  • KSDK
  • MQX
  • PEx
  • RTCS

From experimentation and reading the forums, it sure seems like there are combinations of components that do not work together, or might be expected to work together.  It's all very fuzzy to me, and I'd love to see a definitive answer as to what a Freescale developer should be able to expect as far as integration goes.  The fact that some PEx components disappear depending upon the project configuration implies to me that there are some combinations that are not allowed or expected to work together.  Is there a matrix around that shows which combinations work together, and for a given combination, which peripherals actually work?

Since PWM_LDD wasn't an option, I did move forward with fsl_ftm.  I would port this code over to my MQX-enabled project (that does *not* use PEx), but I recently learned that there is a bug in the KSDK that prevents multiple PWM channels on the same FlexTimer from working simultaneously.  I have also found that I cannot specify a different pin for a FTM PWM channel, which complicates things for me when I don't have the flexibility to use the pre-defined pin in the Component Inspector.  I was going to work around this bug by using a PWM channel on a different FTM since I'm using a K64 which has 4 FTMs.

And a last random question -- what does the FSL in "fsl_" components represent?  I was thinking that it stood for something that I could then remember to clue me in on where those components are applicable/compatible, but I have a feeling it just stands for Freescale.  :smileyhappy:

Thanks, David!

0 Kudos
1,305 Views
DavidS
NXP Employee
NXP Employee

Hi David,

Probably should have started a new post from beginning with what you were working with as tools and devices as you have learned are not 100% equal across the board.   Oh well.  Here goes.

The Kinetis MCU family is broad and extensive.  I'll focus mainly on the Kinetis K and L which have been around the longest and we have lots of them.

The tools enablement is in transition which is causing temporary hiccups.  CW10.x fee based product that supported all Kinetis is passing the baton to KDS a free Eclipse based IDE.  A line was drawn in the sand last year to say all new Kinetis devices will be supported in KDS and not CW10.x.  Both KDS and CW10.x has Processor Expert (PE) integrated.  All devices supported in KDS (C:\Freescale\KDS_2.0.0\eclipse\ProcessorExpert\PEx_KDS_2_0_0_Release_Notes.pdf - Section C) can be used with baremetal code customer develops or with PE to generate the code using LDD or Init Components that as same implementation as in CW10.x.

Now for KSDK support (HAL and/or Peripheral Driver support), only the newest Kinetis devices starting with K64/K22 were in the initial drop Sept 2014.  Now with the latest KSDK_1.1.0 (Jan 2105) release many more have been added.  Just look at the KSDK product page to see what is supported (http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KINETIS_SDK&tid=vanKSDK) or look at the KSDK release notes (C:\Freescale\KDS_2.0.0\eclipse\ProcessorExpert\KSDK_1.1.0_Eclipse_Update_Release_Notes.pdf).  Mostly newest devices but a few "older" ones too but not the entire Kinestis K/L families.  As time passes more and more of the older devices will be added into KSDK but not all.  Currently I do not see the K20-72MHz devices on the list as an example.

Now for KDS support of KSDK enabled devices.... Those supported devices have PE support but only for KSDK and not the LDD and Init Components.  So PE in KDS really has two modes of operation depending on which device you target (confusing....).

The KSDK is a static set of drivers/code (nice and allows you to view all the code and enhance if you want) that PE will generate the configuration structures/data for and does not generate the total code-base that PE for older devices does.  Note K64 seems to be the exception to the rule and you can choose KSDK and/or PE.

FSL is the stock ticker and abbreviation for Freescale.

Regards,

David

0 Kudos
1,305 Views
dave408
Senior Contributor II

Hi David, thanks for the really useful answer, and things make more sense now.  I actually did have a separate post for this subject here, but in the process of trying to figure things out, I came across this thread.  The intention was not to hijack it, but it looks like that's what I ended up doing.  :smileyconfused:

0 Kudos
1,305 Views
dave408
Senior Contributor II

Hi David, thanks for posting your project.  I'll load it up now!

EDIT -- I loaded the project, switched to a MK64 component and reconfigured to use 2 PWMs on FTM3 -- works great!  Now I am just wondering about using this with MQX...

1,305 Views
Robinwithu
Senior Contributor I

Hi Luis,

Hope this Application note will be useful for you.

1,305 Views
luissanchez
Contributor II

Hi Robin!!

Thanks a lot for reply me!! I'll read your document :-)

0 Kudos