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.
Revision 0:3e987e5f426b, committed 2010-01-04
- Comitter:
- simon
- Date:
- Mon Jan 04 14:18:40 2010 +0000
- Commit message:
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 3e987e5f426b main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Jan 04 14:18:40 2010 +0000
@@ -0,0 +1,44 @@
+// analog input p20 (ADC0[5], pin 3) test
+
+#include "mbed.h"
+
+int main() {
+
+ // power on, clk divider /4
+ LPC_SC->PCONP |= (1 << 12);
+ LPC_SC->PCLKSEL0 &= ~(0x3 << 24);
+
+ // software-controlled ADC settings
+ LPC_ADC->ADCR = (0 << 0) // SEL: 0 = no channels selected
+ | (25 << 8) // CLKDIV: PCLK max ~= 25MHz, /25 to give safe 1MHz
+ | (0 << 16) // BURST: 0 = software control
+ | (0 << 17) // CLKS: not applicable
+ | (1 << 21) // PDN: 1 = operational
+ | (0 << 24) // START: 0 = no start
+ | (0 << 27); // EDGE: not applicable
+
+ // setup P1_31 as sel 3 (ADC), mode 2 (no pull)
+ LPC_PINCON->PINSEL3 &= ~((unsigned int)0x3 << 30);
+ LPC_PINCON->PINSEL3 |= (unsigned int)0x3 << 30;
+
+ LPC_PINCON->PINMODE3 &= ~((unsigned int)0x3 << 30);
+ LPC_PINCON->PINMODE3 |= (unsigned int)0x2 << 30;
+
+ while(1) {
+ // Select channel and start conversion
+ LPC_ADC->ADCR &= ~0xFF;
+ LPC_ADC->ADCR |= 1 << 5; // ADC0[5]
+ LPC_ADC->ADCR |= 1 << 24;
+
+ // Repeatedly get the sample data until DONE bit
+ unsigned int data;
+ do {
+ data = LPC_ADC->ADGDR;
+ } while ((data & ((unsigned int)1 << 31)) == 0);
+
+ // Stop conversion
+ LPC_ADC->ADCR &= ~(1 << 24);
+
+ printf("0x%3X\n", data);
+ }
+}
diff -r 000000000000 -r 3e987e5f426b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jan 04 14:18:40 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0