AnsweredAssumed Answered

Pit0 Start Stop

Question asked by Pietro di Castri on Apr 21, 2015
Latest reply on Apr 22, 2015 by Pietro di Castri

good mornint

 

I have the following stub of code for PIT0 use.

 

void pit0_init( void )

{

  PIT_DRV_InstallCallback( 0, THIS_PIT_CHANNEL, pit0_isr_cback );

  PIT_DRV_Init( 0, false );

  PIT_DRV_InitChannel( 0, THIS_PIT_CHANNEL, &pit0_user_config );

  timerBase = 0;

  NVIC_SetPriority( g_pitIrqId[ THIS_PIT_CHANNEL ], PIT0_INT_PRIO );

}

 

 

void pit0_start( void )

{

  PIT_HAL_Enable( g_pitBaseAddr[ 0 ] );

    PIT_HAL_SetIntCmd( g_pitBaseAddr[ 0 ], THIS_PIT_CHANNEL, true );

  PIT_DRV_StartTimer( 0, THIS_PIT_CHANNEL );

}

 

 

void pit0_stop( void )

{

  PIT_DRV_StopTimer( 0, THIS_PIT_CHANNEL );

  PIT_HAL_Disable( g_pitBaseAddr[ 0 ] );

    PIT_HAL_SetIntCmd( g_pitBaseAddr[ 0 ], THIS_PIT_CHANNEL, false );

    PIT_HAL_ClearIntFlag( g_pitBaseAddr[ 0 ], THIS_PIT_CHANNEL );

  // CLOCK_SYS_DisablePitClock( 0 );

}

 

If I call the pit0_init() then pit0_start() the timer starts and the interrupt is serviced.

Then I call the pit0_stop(). and again the pit0_start(), the timer does not start...

I need to call again the pit0_init()..

 

Another think I don t understand is why CLOCK_SYS_DisablePitClock( 0 ) is generating a hardware fault...

 

I am using the MK02FN128VFM10 cpu.

 

Suggestions welcome...

Pietro

Outcomes