AnsweredAssumed Answered

Blinking Led using PIT-module

Question asked by Rohan Anand on Dec 13, 2015
Latest reply on Dec 14, 2015 by Mark Butcher

Hello,

I am trying to blink the on-board red led using the PIT-module.The code is as follows:

#include "MKL46Z4.h"

void initPITM(void)

{

  PIT_MCR= 0x00000000;//Module enable

 

 

}

 

 

void delay()

{

 

 

  PIT_LDVAL0=0x00FFFFFF;//Value of timer 0

  PIT_TCTRL0=0x00000001;//Timer enable

  while((PIT_TFLG0 & 0x00000001)==0)

  {

 

 

  }

}

void initLEDR()

{

  SIM_SCGC5=SIM_SCGC5_PORTE_MASK;

  PORTE_PCR29=256;

  GPIOE_PDDR=1u<<29;

}

int main(void)

{

     initLEDR();

     initPITM();

     while(1)

     {

     GPIOE_PDOR=0u<<29;

     delay();

     GPIOE_PDOR=1u<<29;

     delay();

     }

    return 0;

}

When I am debugging this code,it goes to PIT_MCR=0x00000000; and then goes to handler.

Please help.I am unable to find whats wrong with the code?

It goes here and then oscillates back and forth.

ldrr0, =DefaultISR

    bx r0

Outcomes