Keil Logo

Create New Source Files

New File Button You may create a new source file with the menu option File — New. This opens an empty editor window where you can enter your source code. µVision3 enables the C color syntax highlighting when you save your file with the dialog File — Save As... under a filename with the extension *.C. We are saving our example file under the name MAIN.C.

#include <LPC210x.H>                       /* LPC210x definitions */

void wait (void)  {                        /* wait function */
  ;                                        /* only to delay for LED flashes */
}

int main (void)  {
  unsigned int i;                          /* Delay var */
  unsigned int j;                          /* LED var */

  IODIR = 0xFF;                            /* P0.0..7 defined as Outputs */
  while (1) {                              /* Loop forever */
    for (j = 0x01; j < 0x80; j <<= 1) {    /* Blink LED 0, 1, 2, 3, 4, 5, 6 */
      IOSET = j;                           /* Turn on LED */
      for (i = 0; i < 10000; i++)  {       /* Delay for 10000 Counts */
        wait ();                           /* call wait function */
      }
      IOCLR = j;                           /* Turn off LED */
        }
    for (j = 0x80; j > 0x01; j >>=1) {     /* Blink LED 7, 6, 5, 4, 3, 2, 1 */
      IOSET = j;                           /* Turn on LED */
      for (i = 0; i < 10000; i++)  {       /* Delay for 10000 Counts */
        wait ();                           /* call wait function */
      }
      IOCLR = j;                           /* Turn off LED */
    }
  }
}
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.