This is test program of mcp3204. This is operating normally.

Dependencies:   mbed MCP320x TextLCD

Files at this revision

API Documentation at this revision

Comitter:
SK_ROBO_
Date:
Fri Jan 29 03:02:09 2016 +0000
Parent:
0:55aac36c4f0f
Commit message:
Delete debug library.

Changed in this revision

MCP320x.lib Show annotated file Show diff for this revision Revisions of this file
Nucleo_mcp3204test.cpp Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib 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 55aac36c4f0f -r 50f0c5749724 MCP320x.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MCP320x.lib	Fri Jan 29 03:02:09 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/SK_ROBO_/code/MCP320x/#d2c51376ee7c
diff -r 55aac36c4f0f -r 50f0c5749724 Nucleo_mcp3204test.cpp
--- a/Nucleo_mcp3204test.cpp	Thu Jan 28 05:34:51 2016 +0000
+++ b/Nucleo_mcp3204test.cpp	Fri Jan 29 03:02:09 2016 +0000
@@ -1,47 +1,34 @@
 #include "mbed.h"
- 
-SPI spi(D11, D12, D13); // mosi(out), miso(in), sclk(clock)
-DigitalOut cs(D10); // cs (the chip select signal)
- 
-Serial pc(USBTX, USBRX); // tx, rx ( the usb serial communication )
- 
-int main() {
-    // Setup the spi for 7 bit data, high steady state clock,
-    // second edge capture, with a 1MHz clock rate
-    spi.format(7,0);
-    spi.frequency(1000000);
- 
+#include "TextLCD.h"
+
+#include "MCP320x.h"
+
+#define MOSI    D11
+#define MISO    D12
+#define CLK     D13
+#define CS      D10
+#define CHIPFAMILLY     CMCP320x_SPI::_3204
+#define FREQ    100000
+
+TextLCD lcd(PB_0, PB_1, PA_12, PF_0, PF_1, PA_8, TextLCD::LCD20x2); // rs, e, d4-d7
+
+CMCP320x_SPI mcp3204(MOSI, MISO, CLK, CS, CHIPFAMILLY, FREQ);
+
+int main()
+{
     // notify the user that we are starting with the ADC communication
-    pc.printf("Starting ADC interaction\n");
-    
+    printf("Starting ADC interaction\n");
+
     // lets just do this forever
     while (1) {
- 
-        // Select the device by seting chip select low
-        cs = 0;
- 
-        // sending the 6 bits + 1 bit to ignore the null bit
-        // coming from the device, so the data that is sent is 1100000
-        spi.write(0x60);
-        
-        // now the device sends back the readings 12 bits, 7 bits at a time
-        uint8_t high = spi.write(0x00);
-        uint8_t low = spi.write(0x00);
- 
-        // shift out the right bits
-        low = ( high << 5 ) | (low >> 2);
-        high = high >> 3;
-        
-        // shift and or the result together
-        int value = ( high << 7 ) | low;
-        
-        // and voila we have the value and we can print it for the user
-        pc.printf("sensor 0 value = %u\n", value);
- 
-        // Deselect the device
-        cs = 1;
- 
+        //lcd.cls();
+        lcd.printf("CH0:%3.2f[deg]\n", mcp3204.Read(CMCP320x_SPI::CH0)/*/ 4095.0f*270.0f */);
+        lcd.printf("CH1:%3.2f[deg]\n", mcp3204.Read(CMCP320x_SPI::CH1)/*/ 4095.0f*270.0f */);
         // delay some time before reading again
-        wait(1);
+        wait(0.5);
+        lcd.printf("CH2:%3.2f[deg]\n", mcp3204.Read(CMCP320x_SPI::CH2)/*/ 4095.0f*270.0f */);
+        lcd.printf("CH3:%3.2f[deg]\n", mcp3204.Read(CMCP320x_SPI::CH3)/*/ 4095.0f*270.0f */);
+        // delay some time before reading again
+        wait(0.5);
     }
 }
\ No newline at end of file
diff -r 55aac36c4f0f -r 50f0c5749724 TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Fri Jan 29 03:02:09 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 55aac36c4f0f -r 50f0c5749724 mbed.bld
--- a/mbed.bld	Thu Jan 28 05:34:51 2016 +0000
+++ b/mbed.bld	Fri Jan 29 03:02:09 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96
\ No newline at end of file