AnsweredAssumed Answered

[HELP] TOF bit from TPM register don't work on KDS 3 Mac version

Question asked by Maxime Dolberg on May 19, 2015
Latest reply on May 26, 2015 by Maxime Dolberg

Hello,

 

I just downloaded KDS 3 on my Mac but I figure out a strange bug ...

 

My project use a custom delay lib ( bare board lib, no PEx). It work very good on KDS 2 both Win7 and Ubuntu systems and I also used many time with Keil µVision. But when I used my delay lib on KDS 3 Mac version, it's not work. It seems that TOF bit from TPM statut & control register never set ( I check it with EmbSys Registers). I didn't notice any increments on CTN register too, maybe that why interrupt flag bit never set . So my code just stuck into an infinity loop at line 18 or 31.

 

Below the code of my delay lib using TPM0 and FRDM-KL25Z. I also tried with TPM1 and even another Freescale board (FRDM-KL26Z), no change

 

I should tested on KDS 3 Win7 version but I don't have enough time right now. I will do it later

 

What going on ? Compiler bug ?

 

 

#include "MKL25Z4.h" #include "TPM.h"   void TPM_init(void) {     SIM->SCGC6 |= SIM_SCGC6_TPM1_MASK;//TPM0 clock activé     SIM->SOPT2 |= SIM_SOPT2_TPMSRC(0x03);//TPM clock source -> MCGIRCLK     TPM0->SC = TPM_SC_CMOD(0x00);//LPTPM desactivé     TPM0->SC |= TPM_SC_PS(0x02);//Prescaler /4 => 4MHz/4 = 4MHz => T = 1µs }  void TPM0_delai_us(int t) {     TPM0->MOD = TPM_MOD_MOD(t);//t*1µs     TPM0->SC |= TPM_SC_TOF_MASK;//Reset TOF bit     TPM0->SC |= TPM_SC_CMOD(0x01);//LPTPM activé compteur interne     while((TPM0->SC & TPM_SC_TOF_MASK)!=TPM_SC_TOF_MASK);     TPM0->SC |= TPM_SC_TOF_MASK;//clear TOF bit }  void TPM0_delai_ms(int t) {     int i;      TPM0->MOD = TPM_MOD_MOD(1000);//t*1µs     TPM0->SC |= TPM_SC_TOF_MASK;//Reset TOF bit     TPM0->SC |= TPM_SC_CMOD(0x01);//LPTPM activé compteur interne     for(i=0;i<=t;i++)     {         while((TPM0->SC & TPM_SC_TOF_MASK)!=TPM_SC_TOF_MASK);         TPM0->SC |= TPM_SC_TOF_MASK;//clear TOF bit     } } 

Outcomes