B.3 PROGRAM .SLAVE

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
manujose
Date:
Tue Dec 14 23:26:42 2010 +0000
Parent:
0:9092ea8d9a6c
Commit message:

Changed in this revision

decl.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
problemb1.h Show annotated file Show diff for this revision Revisions of this file
--- a/decl.h	Sat Dec 04 05:09:46 2010 +0000
+++ b/decl.h	Tue Dec 14 23:26:42 2010 +0000
@@ -25,7 +25,7 @@
 
 DigitalOut myLED(LED1);
 DigitalOut myled2(LED2);
-InterruptIn trig(p16);
+//InterruptIn trig(p16);
 DigitalOut toggle(p16);
 Ticker synch;
 
--- a/main.cpp	Sat Dec 04 05:09:46 2010 +0000
+++ b/main.cpp	Tue Dec 14 23:26:42 2010 +0000
@@ -5,7 +5,7 @@
 
 void hello(void) {
     pc.printf(" Hello World\n");
-    trig.mode(PullUp);
+  //  trig.mode(PullUp);
 }
 
 int main() {
@@ -25,7 +25,7 @@
     
     // 1 PPS Code 
     pps.tv_sec = 10;
-    pps.tv_usec = 500000;  
+    pps.tv_usec = 700000;  
     runAtTime(&pinToggle,&pps);
     
     
--- a/problemb1.h	Sat Dec 04 05:09:46 2010 +0000
+++ b/problemb1.h	Tue Dec 14 23:26:42 2010 +0000
@@ -44,7 +44,7 @@
     //LPC_TIM0->MR0 = 0x5370;
     if (LPC_TIM0->IR&1) {
         gTime++;
-        pc.printf("gtime++ %X",LPC_TIM0->IR);
+       // pc.printf("gtime++ %X",LPC_TIM0->IR);
     } 
     
     if((LPC_TIM0->IR >> 1)&1 ){ //RUN THE RUNAT TIME HIT
@@ -126,7 +126,7 @@
 }
 void runAtTrigger(void(*trigFunc)(timeval *tv)) {
     gtrigFunc = trigFunc;
-    trig.rise(&trigger);
+  //  trig.rise(&trigger);
    // pc.printf("Runing runAtTrigger\n");
 }
 
@@ -168,7 +168,7 @@
     
     sync.attach(&calculate_offset); 
     
-    //pc.printf(" \n t1= %X, t2 = %X, t3 = %X, t4 = %X",t1.t,t2.t,t3.t,t4.t);
+   // pc.printf(" \n t1= %X, t2 = %X, t3 = %X, t4 = %X",t1.t,t2.t,t3.t,t4.t);
 
 // account for the case where the TC has overflowed.
 
@@ -192,20 +192,29 @@
     if(LPC_TIM0->TC >  RESET_42)
         LPC_TIM0->TC = LPC_TIM0->TC - RESET_42;
         
+ //   pc.printf(" offset = %d\n",offset);
     offset = 0; 
     while(sync.readable())
     sync.getc(); 
  
-    //pc.printf(" offset = %d\n",offset); 
+     
 }
 
 
 void pinToggle(void)
 {
+    
     toggle = !toggle; 
-    myLED = !myLED; 
-   // pc.printf("\nToggle");
-    pps.tv_sec++; 
+    myLED = !myLED;
+  // pc.putc('T'); 
+//   pc.printf("\nToggle");
+    pps.tv_usec+=500000;
+    if(pps.tv_usec == 1200000)
+    {
+       pps.tv_usec = 200000;
+       pps.tv_sec++; 
+    }
+    
     runAtTime(&pinToggle,&pps);
       
 }