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.
Fork of SPI_MCP3002 by
Revision 1:178a0f92d2ab, committed 2018-10-30
- Comitter:
- acabate
- Date:
- Tue Oct 30 22:11:27 2018 +0000
- Parent:
- 0:08026df17556
- Commit message:
- Lab 10/30/18
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 08026df17556 -r 178a0f92d2ab main.cpp --- a/main.cpp Mon Oct 02 01:52:48 2017 +0000 +++ b/main.cpp Tue Oct 30 22:11:27 2018 +0000 @@ -19,6 +19,7 @@ spi.format(8,0); spi.frequency(10000); int data1, data2, mask, channel; + aout = 0.0; // Supply voltage is nominally 3.3V float VCC=3.3, vIn; while(1) { @@ -30,8 +31,9 @@ } cs = 0; data1 = spi.write(mask); + cs = 1; data2 = spi.write(0); - cs = 1; + //cs = 1; // Format for MSB set data1 &= 0x03; // keep only three bits data2 |= data1 << 8 ; // shift and add to LSB @@ -39,6 +41,9 @@ vIn = VCC*data2/1000.; pc.printf("Channel %i Voltage is %f \r\n",channel,vIn); } - wait(1); + aout = aout + 0.1; + float volt = aout; + pc.printf("Analog output of mbed is %f \r\n", volt); + //wait(1); } }