Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 //================================================== 00002 //Reading PWM pulse 00003 // 00004 //MPU board: mbed LPC1768 00005 //2019/10/13 A.Toda 00006 //================================================== 00007 #include "mbed.h" 00008 00009 //Port Setting 00010 InterruptIn reading_port(p15); 00011 Serial pc(USBTX, USBRX); //UART 00012 00013 //================================================== 00014 //Timer valiables 00015 //================================================== 00016 Timer ch_time;//timer for calculate pulse width 00017 00018 double measured_pre_pulse=0.0; 00019 double measured_pulse=0.0; 00020 00021 //================================================= 00022 //Functions for rising and falind edge interrution 00023 //================================================= 00024 //rise edge 00025 void rising_edge(){ 00026 ch_time.reset();//reset timer counter 00027 measured_pre_pulse=ch_time.read(); 00028 00029 } 00030 00031 //falling edge 00032 void falling_edge(){ 00033 measured_pre_pulse=(ch_time.read()-measured_pre_pulse); 00034 pc.printf("The pulse width=%f\r\n",measured_pre_pulse); 00035 } 00036 00037 //================================================== 00038 //Main 00039 //================================================== 00040 int main() { 00041 00042 //UART initialization 00043 pc.baud(115200); 00044 00045 //Logging starts 00046 pc.printf("Reading starts."); 00047 00048 //timer starts 00049 ch_time.start(); 00050 00051 //declare interrupitons 00052 reading_port.rise(rising_edge); 00053 reading_port.fall(falling_edge); 00054 00055 //while 00056 while(1) { 00057 wait(0.01); 00058 }//while ends 00059 00060 }//main ends
Generated on Tue Aug 16 2022 23:15:54 by
1.7.2