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.
Dependents: FirstTest WaveSim IO-dma-memmem DACDMAfuncgenlib ... more
Diff: example2.cpp
- Revision:
- 11:19009be5a0e7
- Parent:
- 10:3a46c1e383a4
--- a/example2.cpp Fri Mar 11 13:47:23 2011 +0000
+++ b/example2.cpp Sun Mar 13 12:46:55 2011 +0000
@@ -8,7 +8,7 @@
#include "mbed.h"
#include "MODDMA.h"
-#define SAMPLE_BUFFER_LENGTH 30
+#define SAMPLE_BUFFER_LENGTH 32
DigitalOut led1(LED1);
DigitalOut led2(LED2);
@@ -27,7 +27,7 @@
int main() {
// Create a buffer to hold the ADC samples and clear it.
- // Note, we are going to sample three ADC inputs so they
+ // Note, we are going to sample two ADC inputs so they
// end up in this buffer "interleaved". So you will want
// a buffer twice this size to a real life given sample
// frequency. See the printf() output for details.
@@ -40,18 +40,16 @@
// Power up the ADC and set PCLK
LPC_SC->PCONP |= (1UL << 12);
- LPC_SC->PCLKSEL0 &= ~(3UL << 16); // PCLK = CCLK/4 96M/4 = 24MHz
+ LPC_SC->PCLKSEL0 &= ~(3UL << 24); // PCLK = CCLK/4 96M/4 = 24MHz
- // Enable the ADC, 12MHz, ADC0.0, .1 & .2
- LPC_ADC->ADCR = (1UL << 21) | (1UL << 8) | (7UL << 0);
+ // Enable the ADC, 12MHz, ADC0.0 & .1
+ LPC_ADC->ADCR = (1UL << 21) | (1UL << 8) | (3UL << 0);
// Set the pin functions to ADC
- LPC_PINCON->PINSEL1 &= ~(3UL << 14); /* P0.23, Mbed p15 AD0.0 */
+ LPC_PINCON->PINSEL1 &= ~(3UL << 14); /* P0.23, Mbed p15. */
LPC_PINCON->PINSEL1 |= (1UL << 14);
- LPC_PINCON->PINSEL1 &= ~(3UL << 16); /* P0.24, Mbed p16 AD0.1 */
+ LPC_PINCON->PINSEL1 &= ~(3UL << 16); /* P0.24, Mbed p16. */
LPC_PINCON->PINSEL1 |= (1UL << 16);
- LPC_PINCON->PINSEL1 &= ~(3UL << 18); /* P0.25, Mbed p17 AD0.2 */
- LPC_PINCON->PINSEL1 |= (1UL << 18);
// Setup the serial port to print out results.
pc.baud(115200);
@@ -85,7 +83,7 @@
// just set the global flag.
LPC_ADC->ADINTEN = 0x100;
- // Enable burst mode on inputs 0, 1 and 2.
+ // Enable burst mode on inputs 0 and 1.
LPC_ADC->ADCR |= (1UL << 16);
while (1) {