example for using fast pwm

Dependencies:   FastPWM mbed

Example for the use of fast pwm on an stm nucleo F302R8.

Revision:
1:1ac1f46ae264
Parent:
0:e89048c4d596
--- a/main.cpp	Tue Mar 01 10:39:08 2016 +0000
+++ b/main.cpp	Tue Mar 01 10:57:29 2016 +0000
@@ -6,7 +6,8 @@
 //seting analog input  
     AnalogIn analog_value(A0);
 //setup serial coms
-Serial pc(USBTX, USBRX);
+    Serial pc(SERIAL_TX, SERIAL_RX);
+    DigitalOut myled(LED1);
 //setup ticker 
     Ticker toggle_sample_ticker;
 //setup gobal variables
@@ -15,7 +16,7 @@
     float sample[8];
 //setup interrupt sample function
     void sampling() {
-            if(count<8) {
+            if(count<=8) {
                  count=count+1;
                  sample[count]=(analog_value.read());
                  SampleSum=(sample[0]+sample[1]+sample[2]+sample[3]+sample[4]+sample[5]+sample[6]+sample[7]);
@@ -32,6 +33,8 @@
                             }
 
 int main() {
+  int i = 1;
+  pc.printf("Hello World !\n");
 //setup pwm
     uint32_t period_ticks=720;
     buck.prescaler(1);
@@ -44,7 +47,10 @@
     boost.pulsewidth_us(3);
 //boostpwm(10);   
     while(1) {
-                toggle_sample_ticker.attach(&sampling, 0.0000011); // will cal mycode every 1/8000 second
-                pc.printf("\t%i\n",SampleSum);
+               // toggle_sample_ticker.attach(&sampling, 0.1); // will cal mycode every 1/8000 second
+                //test serial
+                      wait(1);
+                        pc.printf("This program runs since %d seconds.\n", SampleAverage);
+                int SampleAverage=SampleSum/9;
     }
 }