IRQ problems with Kinetis SDK 1.3

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

IRQ problems with Kinetis SDK 1.3

Jump to solution
905 Views
anther
Contributor II

Hi everyone,

I'm working in a new project with a KL02 KSD 3.0 and SDK 1.3. I've created a small program and I'm using  a LPTMR to increment a variable but the program never jumps to the interrutp function.

Does anyone know what could be the problem?

I'm using the folowing sample code:

 

main.c

int main(void)

{

    // Configure LPTMR.

    lptmr_state_t lptmrState;

    lptmr_user_config_t lptmrUserConfig =

    {

        .timerMode            = kLptmrTimerModeTimeCounter, /*! Use LPTMR in Time Counter mode */

        .freeRunningEnable    = false, /*! When hit compare value, set counter back to zero */

        .prescalerEnable      = false, /*! bypass prescaler */

        .prescalerClockSource = kClockLptmrSrcLpoClk, /*! use 1kHz Low Power Clock */

        .isInterruptEnabled   = true

    };

 

    // Configure board specific pin muxing

    hardware_init();

 

    // Initialize LPTMR

    LPTMR_DRV_Init( 0, &lptmrState, &lptmrUserConfig );

 

    // Set the timer period for 1 msecond

    LPTMR_DRV_SetTimerPeriodUs( 0, 1000000 );

 

    // Specify the callback function when a LPTMR interrupt occurs

    LPTMR_DRV_InstallCallback( 0, LptmrTick );

    // Start counting

    LPTMR_DRV_Start( 0 );

 

    for (;;)                                         // Forever loop

    {

        //__asm("NOP");

        if( systemCounter != 0 )

        {

          if( systemCounter > 2 )

          {

              systemCounter = 0;

          }

        }

        else

        {

          __asm("NOP");

          LPTMR_HAL_GetCounterValue(LPTMR0);

          //LPTMR_DRV_IRQHandler(0U);

        }

    }

}

 

static void LptmrTick( void )

{

    systemCounter++;

}

fsl_lptmr_irq.c

 

#if (FSL_FEATURE_SOC_LPTMR_COUNT > 0U)

void LPTMR0_IRQHandler(void)

{

    LPTMR_DRV_IRQHandler(0U);

}

#endif

 

Thankyou.

Labels (1)
1 Solution
493 Views
DavidS
NXP Employee
NXP Employee

Hi Antonio,

PTB5 is a NMI pin by default out of POR.  So if you have it tied low, when the interrupts are enabled the NMI interrupt is generated.

Can you try your system with PTB5 pulled high?

Or can you try to disable the NMI functionality in the FTFA_FOPT field by setting FTFA_FOPT[NMI_DIS]=0 ?

Regards,

David

View solution in original post

0 Kudos
4 Replies
493 Views
DavidS
NXP Employee
NXP Employee

Hi Anthonio,

I tried the example:

C:\Freescale\KSDK_1.3.0\examples\frdmkl02z\driver_examples\lptmr\kds by loading up the *.wsd and compiling the library and then application.

It worked for me.

I then added in your code and basically had to add prototype to the LptmrTick() routine and it works fine too.

Attached is my main.c .

Have you done the Hepl->Install New Software...then select Work with: Freescale KDS Update Site - http://freescale.com/lgfiles/updates/Eclipse/KDS

Then check all the stuff to ensure you have updated the tool environment?

Regards,

David

0 Kudos
493 Views
anther
Contributor II

Hi David,

Thanks for your help but the problem persist. I don't work with the eval board, I'm working with a propietary board based on MKL02Z32VFG4.

Today I tried the Freescale sample but this doesn't work. As unusual in my board I have tied to ground PTB5 but I've configured as GPIO with this line PORT_HAL_SetMuxMode( PORTB, 5, kPortMuxAsGpio);

These are the screenshot:

Before int: The LPTMR interruption is properly configured.

before_int.png

After int : The interrruption flag is set but the code doesn't jump to LPTMR0_IRQHandler function.

after_int_current_data.png

And this is a microcontroller part of my schematic:

schematic.png

Any ideas for how to fix this problem?

Thanks in advance.

0 Kudos
494 Views
DavidS
NXP Employee
NXP Employee

Hi Antonio,

PTB5 is a NMI pin by default out of POR.  So if you have it tied low, when the interrupts are enabled the NMI interrupt is generated.

Can you try your system with PTB5 pulled high?

Or can you try to disable the NMI functionality in the FTFA_FOPT field by setting FTFA_FOPT[NMI_DIS]=0 ?

Regards,

David

0 Kudos
493 Views
anther
Contributor II

Hi David,

Thanks for your help, I've cleared NMI_DIS bit and the program works perfectly.

As clarification FTFA is a read only registry and is not possible modifying its value as others in program code. This registry is loaded during the reset sequence from program flash at the address 0x400 ( in kl02 microcontrollers ). For this reason if you want to change the FTFA values you need to modify the values in the binary file.  A easy way to do this is modifying the values from startup_Microcontroller.s in my case startup_MKL02Z4.s

/* Flash Configuration */

    .section .FlashConfig, "a"

    .long 0xFFFFFFFF

    .long 0xFFFFFFFF

    .long 0xFFFFFFFF

    .long 0xFFFFFBFE

    .text

    .thumb

With the linker file you can verify the location of the section, in this case .FlashConfig and the files of this registry are in the specifc microcontroller header file. In my case MKL02Z4.h

To verify tha your code works properly, you can check the address 0x400 in the binary file:

binary_file.png

Regards,

Antonio