Unexpected behavior in kl25z TPM.

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

Unexpected behavior in kl25z TPM.

Jump to solution
1,339 Views
Mockingbird
Contributor I

I am programming a kl25z on a Freescale FRDM-KL25Z board using assembly language. My IDE is CodeWarrior 10.7. My program is a simple LED-blink program. I use the TPM output compare interrupt to schedule the blinks.

The program works correctly when I connect TPM to the FLL. The program fails to work when I connect TPM to MCGIRCLK. The only differences between the two versions of the program are in SIM_SOPT2 TPMSRC (which selects the TPM clock) and in TPM0_SC PS (the TPM clock prescaler).

When I write corresponding C-programs with help of the Processor Expert, the C- program works both when TPM is connected to FLL and when TPM is connected to MCGIRCLK.

Why won't my assembly-language program work with TPM connected to MCGIRCLK?

0 Kudos
Reply
1 Solution
1,182 Views
mjbcswitzerland
Specialist V

Timothy

Load the code that works, let if run, then pause it and do a screen shot of all relevant registers.

Then load your code and do the same.

You should be able to see a difference in a register somewhere showing what is missing to get it working the same way.

Regards

Mark

View solution in original post

0 Kudos
Reply
4 Replies
1,182 Views
mjbcswitzerland
Specialist V

Hi Timothy

You probably need to enable the MCGIRCLK clock gate with IRCLKEN in register MCG_C1.
To get 4MHz MCGIRCLK remove its divider to get 4MHz clock (MCG_S = 0) and select 4MHz instead of 32kHz with IRCS in register MCG_C2.

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html
Kinetis KL25, KL26, KL27, KL28, KL82, KL43, KL46
- http://http://www.utasker.com/kinetis/FRDM-KL25Z.html
- http://www.utasker.com/kinetis/TWR-KL25Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL26Z.html
- http://www.utasker.com/kinetis/TEENSY_LC.html
- http://www.utasker.com/kinetis/FRDM-KL27Z.html
- http://www.utasker.com/kinetis/Capuccino-KL27.html
- http://www.utasker.com/kinetis/FRDM-KL28Z.html
- http://www.utasker.com/kinetis/FRDM-KL82Z.html
- http://www.utasker.com/kinetis/FRDM-KL43Z.html
- http://www.utasker.com/kinetis/TWR-KL43Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL46Z.html
- http://www.utasker.com/kinetis/TWR-KL46Z48M.html

Build with: CW10.x, KDS, MCUXpresso, IAR, Keil, Greenhills, Crossworks, CooCox, Atollic, S32 Design Studio, GNU Make and Visual Studio

HW timers: http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M

For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html

0 Kudos
Reply
1,182 Views
Mockingbird
Contributor I

The code I attached shows that IRCLKEN is already set.  The debugger confirms this.

0 Kudos
Reply
1,183 Views
mjbcswitzerland
Specialist V

Timothy

Load the code that works, let if run, then pause it and do a screen shot of all relevant registers.

Then load your code and do the same.

You should be able to see a difference in a register somewhere showing what is missing to get it working the same way.

Regards

Mark

0 Kudos
Reply
1,182 Views
Mockingbird
Contributor I

Thanks, that helped.  It turns out the instruction to set IRCLKEN wasn't written correctly; I wasn't taking proper account of the little-endian architecture.

0 Kudos
Reply