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 #include "mbed.h" 00002 00003 // Scans through the D/A converter values, and copies a set of A/D converter values to file on USB local filesystem. 00004 // Connect pin 18 to pin 17. 00005 00006 AnalogOut aout(p18); 00007 AnalogIn ain(p17); 00008 LocalFileSystem local("local"); // Create the local filesystem under the name "local" 00009 00010 const int N = 100; 00011 int i; 00012 int n; 00013 unsigned short x[N]; 00014 //short trim = 3; // ADC trim; appears this is added to the ADC readings (i.e, -8 gives results in too low readings, 0 gives about correct readings, +3 gives really correct readings for my system, and +7 gives too high readings.) 00015 00016 int main() { 00017 FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing 00018 //LPC_ADC->ADTRM&=~0x00F0; //zero the ADC trim bits 00019 //LPC_ADC->ADTRM|=(trim<<4) & 0x00F0; //set the trim 00020 //LPC_SC->PCONP &= ~(1<<30); //optionally power down various parts of the lpc1768 00021 //LPC_SC->PCONP &= ~(1<<10); 00022 //LPC_SC->PCONP &= ~(1<<27); 00023 for (i=0;i<1024;i++) { 00024 aout.write_u16(i<<6); 00025 wait(0.001); 00026 for (n=0;n<N;n++) { 00027 x[n]=ain.read_u16(); 00028 } 00029 fwrite(x,sizeof(x[0]),sizeof(x)/sizeof(x[0]),fp); 00030 } 00031 fclose(fp); 00032 }
Generated on Mon Jul 18 2022 19:55:41 by
1.7.2