default port = GPIO_0

Dependents:   multithread_ADC_timing audio_record_serial_out

Files at this revision

API Documentation at this revision

Comitter:
yutonggu
Date:
Sun Dec 08 05:26:48 2019 +0000
Parent:
0:56e4e76188d9
Commit message:
Set system to readADC at 20KHz

Changed in this revision

fastADC.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show diff for this revision Revisions of this file
diff -r 56e4e76188d9 -r d415e0b7dc3e fastADC.cpp
--- a/fastADC.cpp	Wed Dec 04 10:41:22 2019 +0000
+++ b/fastADC.cpp	Sun Dec 08 05:26:48 2019 +0000
@@ -10,11 +10,13 @@
     ADC1->CR2        &= ~(3 << 24);          /* set resolution to 12 bits        */
     ADC1->CR2        |= 1 << 0;             /* turn on ADC                   */
     while(!(ADC1->SR & (1 << 6)));
+    while((ADC1->SR & (1 << 8)));
 }
 
 uint16_t readADC(){
-    while(!(ADC1->SR & (1 << 6)));          /* Wait for ADC to be available */
     ADC1->CR2 |= 1 << 30;                   /* Start new conversion               */ 
     while(!(ADC1->SR & (1 << 1)));          /* If conversion has finished         */
+    while(!(ADC1->SR & (1 << 6)));
+    while((ADC1->SR & (1 << 8)));
     return (uint16_t) ADC1->DR & 0xFFFF;    /* Read AD converted value            */
 }
\ No newline at end of file
diff -r 56e4e76188d9 -r d415e0b7dc3e mbed-os.lib
--- a/mbed-os.lib	Wed Dec 04 10:41:22 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://github.com/ARMmbed/mbed-os/#679d24833acf0a0b5b0d528576bb37c70863bc4e