I get stuck programming a timer register in DefaultISR loop with kl46z

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

I get stuck programming a timer register in DefaultISR loop with kl46z

1,007 Views
floridjam
Contributor II

Hi everybody.

I'am developing with a freedom-kl46z board. I have been to the forum but I didn't find something which could help me.

In fact I'am programming the TPM0 but when the debugger arrive to this line :

TPM0_SC |= TPM_SC_PS(5);

The program go to the startup_MKL46Z4.S and stay to this loop :

DefaultISR:
ldr r0, =DefaultISR
bx r0

I really don't know what to do. I've read this post :

https://community.nxp.com/message/534876 

But I'am sure I use the right component. 

If somebody have the same problem, could you help me ?

Here is the code I use to program my Tpm0 :

//ENable clk for timer 0
SIM_SOPT4 |= 01000000;
//Enable MCGIRCLK p126
MCG_C1 |= 0x2;
//CHoose MCGIRCLK for TPM p132
SIM_SOPT2 = 0x03000000;

//32 prescaler 4MHZ/32 = 125 khz
TPM0_SC |= TPM_SC_PS(5);
//125KHz/125 = 1 Khz
TPM0_MOD = 125;

//Enable interrupt
TPM0_SC |= 1<<6;
NVIC_EnableIRQ(17);

//Module clock for timer 0
TPM0_SC |= 0x08;

Best regards

0 Kudos
3 Replies

603 Views
floridjam
Contributor II

Thank you for both of you. It come from there I forget to enable the TMP module clock before.

0 Kudos

603 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Florian,

As Mark said that you should set the TPM0 bit in the SIM_SCGC6 register so that you can write TPM0 register.

SIM_SCGC6 |= 0x01000000;

If you use internal clock MCGIRCLK as tick to drive TPM0  module, Pls follow up the procedure:

1)set CMOD bits in TPM0_SC as 2b"01

TPM0_SC |= 1<<3;   //01 TPM counter increments on every TPM counter clock

2)select the MCGIRCLK as clock source for the TPM0 module

//Enable MCGIRCLK p126
MCG_C1 |= 0x2;

SIM_SOPT2 = 0x03000000;

Hope it can help you

BR

XiangJun Rong

603 Views
mjbcswitzerland
Specialist V

Hi

You have forgotten to enable the TMP module before access.
You need to add something like
POWER_UP(6, SIM_SCGC6_FTM0);
This equates to
SIM_SCGC6 |= 0x01000000;
for TMP0 in the KL46 if you don't require portability.

Regards

Mark
Kinetis for professionals: http://www.utasker.com/kinetis.html
HW Timer guide: http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF
Full KL46 solution to accelerate project developments: http://www.utasker.com/kinetis/FRDM-KL46Z.html / http://www.utasker.com/kinetis/TWR-KL46Z48M.html