DIY timer functions testing notes

Now I am using my home made timers to switch on LED for half a second, then on a second.  So far so good.

.END

// ****************************************************************************
// Program - Blink LED
// Description - Blink LED
// Author - TL Fong
// Version - 0.35
// Date - 2013jul11hkt0954
// License - Free
// Hardware - Somy ARM Cortex M0 LPC1114/301 Learning Board 
// Software - Keil uVision 4.71.2.0 ARM compiler toolchain
// Hardware configuration notes
//   1. LED1 is connected to PIO1-8 
// ****************************************************************************

#include <stdio.h>
#include "LPC11xx.h"

void setPort1Pin8ToOutput() // PIO1_8 for LED1 set to output
  {
  LPC_GPIO1->DIR |= (1 << 8);
  }

void setPort1Pin8Low() // PIO1_8 Low = LED1 on
  {
  LPC_GPIO1->DATA &= ~(1 << 8);
  }

void setPort1Pin8High() // PIO1_8 High = LED1 off
  {  
  LPC_GPIO1->DATA |= (1 << 8);
  }

void delaySecond(int count)
  { 
int i, j;
while (count--)
{
  i = 0x3F;
while (i--)
 {
        j = 0x000CBFF;
while (j--)
          {
       }
}
     }
}

void delayTenthSecond(int count)
  {
int i, j, k;
for (i = 0; i < count; i++)
    {
for (j = 0; j < 0x4; j++)
 {
        for (k = 0; k < 0x000BB00; k++)
          {
       }
}
     }
}

int main()
  {
  setPort1Pin8ToOutput(); // PIO1_8 for LED1 pin set to output
  while (1)
 {  
 setPort1Pin8Low(); // LED on
    delayTenthSecond(5);
    setPort1Pin8High(); // LED off
    delaySecond(1);
    }
  }

// ****************************************************************************
// End of Program
// ****************************************************************************

No comments:

Post a Comment