LED BLINK PURE C-CODE WITH DELAY

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
AshokK
Date:
Tue May 27 12:50:43 2014 +0000
Commit message:
PROGRAM TO BLINK LED WITHOUT USING DIGITAL OUT AND WAIT FUNCTION(IT IS A PURE C CODE FOR LED BLINK AND DELAY)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 0864ce74d7b0 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 27 12:50:43 2014 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#define PRESCALAR 25000    ///(i,e 
+Serial pc(USBTX, USBRX);
+void pclock()
+{
+     LPC_SC->PCONP |= (1<<15); // power up GPIO
+     LPC_SC->PCONP|=(1<<1);///////conp for timer
+    LPC_SC->PCLKSEL0|=(0<<3);////cclk/4
+    }
+void inittimer()
+{
+    pc.printf("timer\n");
+    LPC_TIM0->CTCR&= ~(1<<0);// SELECT TIMER
+    LPC_TIM0->PR = PRESCALAR-1;/// ASSIGN PRESCALAR
+    int value=LPC_TIM0->PR;
+    pc.printf("%d\n",value);
+    LPC_TIM0->TCR=(1<<0);// enable timer
+    LPC_TIM0->TCR =(1<<1);/// RESET TIMER
+}    
+void delay ( unsigned int millisec)
+{
+     pc.printf("millisec\n");
+     LPC_TIM0->TCR = (1<<1);///n RESET TIMER
+     LPC_TIM0->TCR = (1<<0);// enable timer
+     pc.printf("%d\n",LPC_TIM0->TC); 
+     while(LPC_TIM0->TC < millisec);
+     LPC_TIM0->TCR&= ~(1<<0);// disable timer
+     pc.printf("disabled\n");
+}
+ int main()
+ { 
+ pclock();
+ inittimer();
+ 
+ while(1)
+ {
+   int value= LPC_TIM0->TC;
+   pc.printf("values %d",value);
+  LPC_PINCON->PINSEL3|=(1<<4);///LED 1 COONECTEED TO P1.20
+    delay(500);
+     LPC_PINCON->PINSEL3 &= ~(1<<4);
+    delay(500);
+  
+  }
+     }
+     
\ No newline at end of file
diff -r 000000000000 -r 0864ce74d7b0 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue May 27 12:50:43 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877
\ No newline at end of file