Clock Cofiguration for TIMER

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Clock Cofiguration for TIMER

6,289件の閲覧回数
yashkumar
Contributor III

Hi ,

I am using the S32KXXX micro in my project . I want to use LPTMR module to produce delay in my application.

I have studied all LPTMR ,LPIT and FTM module of this controller .

I want to use MPTMR module to produce delay of 10 Milli-second.I want use crystal frequency to tick the my LPTMR.

My crystal frequency is 16 MHz .every thing is ok as for as concern of LPTR module .

I want help to configure my clock that is being used for My LPTMR module.

 

4-5 :TPS ->Timer Pin Select
Configures the input source to be used in Pulse Counter mode. TPS must be altered only when the
LPTMR is disabled. The input connections vary by device. See the chip configuration information about
connections to these inputs.
00b - Pulse counter input 0 is selected. -> SIRCDIV2_CLK
01b - Pulse counter input 1 is selected. -> LPO1K_CLK
10b - Pulse counter input 2 is selected.->CLK32K
11b - Pulse counter input 3 is selected.-> any of the 7 clock option of PCC module.

i want to use "11" TPS value means any of the clock option from PCC module.

 

and also i want know of the role of SCG module for the configuration of clock for LPTMR as i am using crystal friquency(16 MHz) .

 

 

Please help me , i need your kind support .

ラベル(1)
17 返答(返信)

4,192件の閲覧回数
shaileshagrahar
Contributor III

Hi Lukas,

I am getting strange behavior in my FTM module so I have one question what is clock frequency going to the CORE_CLK in above example hello-Interrupt code ( attached hello-Interrupt.zip). and what is Crystal value used for this.

 i am taking all the function for clock setting same as given in hello-Interrupt example .

 

Please help me on that , so urgent .

0 件の賞賛
返信

4,192件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

You can see all the numbers in my previous post:

https://community.nxp.com/thread/434835#comment-853480 

Lukas

4,191件の閲覧回数
yashkumar
Contributor III

Sorry in above post i was unable to attach.So written below:

void init_IRQs (void) {
    FSL_NVIC->ICPR[1] = 1 << (50% 32);  /* IRQ48-LPIT0 ch0: clr any pending IRQ*/
    FSL_NVIC->ISER[1] = 1 << (50 % 32);  /* IRQ48-LPIT0 ch0: enable IRQ */
     FSL_NVIC->IP[50] = 0xA;              /* IRQ48-LPIT0 ch0: priority 10 of 0-15*/
}


void init_LPIT0 (void) {
  PCC->PCCn[PCC_LPIT0_INDEX] = PCC_PCCn_PCS(6);    /* Clock Src = 6 (SPLL2_DIV2_CLK)*/
  PCC->PCCn[PCC_LPIT0_INDEX] |= PCC_PCCn_CGC_MASK; /* Enable clk to LPIT0 regs */
 
  LPIT0->MCR = 0x00000001;    /* DBG_EN-0: Timer chans stop in Debug mode */
                              /* DOZE_EN=0: Timer chans are stopped in DOZE mode */
                              /* SW_RST=0: SW reset does not reset timer chans, regs */
                              /* M_CEN=1: enable module clk (allows writing other LPIT0 regs) */
 
  LPIT0->MIER   = 0x00000004;   /*  nit TIE2=1: Timer Interrupt Enabled fot Chan 0 */
 
   /* Channel 2*/
  LPIT0->TVAL2  = 80000000;    /* Chan_2 Timeout period: 80M clocks */
  LPIT0->TCTRL2 = 0x00000001; /* T_EN=1: Timer channel is enabled */
                       
}

int main(void) {


  init_SOSC_8MHz();        /* Initialize system oscilator for 8 MHz xtal */
  init_SPLL_80MHz();       /* Initialize SPLL to 80 MHz with 8 MHz SOSC */
  NormalRUNmode_80MHz();   /* Init clocks: 80 MHz SPLL & core, 40 MHz bus, 20 MHz flash */
  init_IRQs();             /* Enable desired interrupts and priorities */
  init_LPIT2();            /* Initialize PIT0 for 1 second timeout  */

  for (;;) {
   
  }
}

void LPIT0_Ch2_IRQHandler (void) {

  LPIT0->MSR |= LPIT_MSR_TIF2_MASK; /* Clear LPIT0 timer flag 0 */
}

0 件の賞賛
返信

4,191件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I just realized that all LPIT channels are assigned to single interrupt vector IRQ 48.

You have to configure:

void init_IRQs (void) {
    FSL_NVIC->ICPR[1] = 1 << (48% 32);  /* IRQ48-LPIT0 ch0: clr any pending IRQ*/
    FSL_NVIC->ISER[1] = 1 << (48 % 32);  /* IRQ48-LPIT0 ch0: enable IRQ */
     FSL_NVIC->IP[48] = 0xA;              /* IRQ48-LPIT0 ch0: priority 10 of 0-15*/
}

And then use LPIT0_Ch0_IRQHandler. At the beggining of handler, check the MSR register to see which interrupt flag is set.

It looks like the documentation needs to be updated.

Regards,

Lukas

4,191件の閲覧回数
yashkumar
Contributor III

Hi Lukas,

Thanks!,My issue  already resolved and  yes after long debugging and some code implementation  , i have also  found for every channel there is single interrupt vector IR.

0 件の賞賛
返信

4,191件の閲覧回数
yashkumar
Contributor III

Hi Lukas,

Thanks , i have used above code it is working fine .I am trying to write the same code for LPIT channel 2 .

and i have attached the code with little bit modification for LPIT channel_2.

I want to 2 channel for producing one more interrupt for other ISR. but i am not getting my ISR being excuted .

Mi LPIT2_IRQ_handler() is not being executed .

0 件の賞賛
返信

4,191件の閲覧回数
yashkumar
Contributor III

Hi Lukas,

I have used project "hello_interrupt" in Design studio. Now i am using IAR Embeded Work bench .I have created a new project and added the elf file for debugging purpose .

How i can get the the .exe or .hex or .s19 file , so that i can flash this in our micro S32K1xx .So that i can debug my code .

Please help me.

Thanks!

0 件の賞賛
返信

4,191件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

elf file should be sufficient. It contains binary image and all debugging information in dwarf2 format. So, it is possible to use any debugger supporting dwarf2 for debugging.

Another option is to create new project in IAR, copy the C code from hello_interrupt and compile/debug the project directly in IAR.

Regards,

Lukas

4,191件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

this diagram from reference manual should help to set the clocks:

pastedImage_1.png

Required clock must be initialized as needed in SCG module.

Regards,

Lukas

4,191件の閲覧回数
yashkumar
Contributor III

Thanks! 

0 件の賞賛
返信

4,191件の閲覧回数
yashkumar
Contributor III

Which module controls the interrupt , generated by LPTMR , LPIT and FTM module ,if these modules are working as interrupt source .For this i have studied the 3.2 Nested Vectored Interrupt Controller (NVIC)
Configuration of reference manual , but here is on LPTMR module only for time specific .

I want to know also for LPIT and FTM module. Also I have gone through the NVIC of cotex-M4  on ARM site, but not found there specific to theses modules. 

Please guide me on this  .

0 件の賞賛
返信

4,191件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

do you use S32 Design Studio? There's an example for LPIT interrupt:

c:\Freescale\S32_ARM_v1.2\S32DS\Examples\S32K144\hello_interrupts\

The project is attached for your reference.

Regards,

Lukas

4,192件の閲覧回数
yashkumar
Contributor III

Hi Lukas,

I am getting strange behavior in my FTM module so I have one question what is clock frequency going to the CORE_CLK in above example hello-Interrupt code ( attached hello-Interrupt.zip). and what is Crystal value used for this.

Please help me on that , so urgent .

Thanks!

0 件の賞賛
返信

4,192件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I can see in the example:

  init_SOSC_8MHz();        /* Initialize system oscilator for 8 MHz xtal */
  init_SPLL_80MHz();       /* Initialize SPLL to 80 MHz with 8 MHz SOSC */
  NormalRUNmode_80MHz();   /* Init clocks: 80 MHz SPLL & core, 40 MHz bus, 20 MHz flash */

So, the CORE_CLK should be 80MHz.

Regards,

Lukas

4,192件の閲覧回数
yashkumar
Contributor III

Hi,

Thanks!,it was really helpful for me.

Could you please help me also ,how i can install S32 Design Studio.

Thanks!

0 件の賞賛
返信

4,191件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

 

open this page:

http://www.nxp.com/files/software_development_tools/ide-debug/S32DS-ARM.html

log in and download the exe file (about 800MB). Run the file and follow the wizard.

Then you will need the license. You will receive it via email or you can open your account on nxp.com and here you can find it in “Software Licensing and Support” section.

 

Regards,

Lukas

4,191件の閲覧回数
yashkumar
Contributor III

Please help on this ,if any body can. It is very urgent .

0 件の賞賛
返信