This is test program of mcp3204. This is operating normally.
Dependencies: mbed MCP320x TextLCD
Nucleo_mcp3204test.cpp@1:50f0c5749724, 2016-01-29 (annotated)
- Committer:
- SK_ROBO_
- Date:
- Fri Jan 29 03:02:09 2016 +0000
- Revision:
- 1:50f0c5749724
- Parent:
- 0:55aac36c4f0f
Delete debug library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SK_ROBO_ | 0:55aac36c4f0f | 1 | #include "mbed.h" |
SK_ROBO_ | 1:50f0c5749724 | 2 | #include "TextLCD.h" |
SK_ROBO_ | 1:50f0c5749724 | 3 | |
SK_ROBO_ | 1:50f0c5749724 | 4 | #include "MCP320x.h" |
SK_ROBO_ | 1:50f0c5749724 | 5 | |
SK_ROBO_ | 1:50f0c5749724 | 6 | #define MOSI D11 |
SK_ROBO_ | 1:50f0c5749724 | 7 | #define MISO D12 |
SK_ROBO_ | 1:50f0c5749724 | 8 | #define CLK D13 |
SK_ROBO_ | 1:50f0c5749724 | 9 | #define CS D10 |
SK_ROBO_ | 1:50f0c5749724 | 10 | #define CHIPFAMILLY CMCP320x_SPI::_3204 |
SK_ROBO_ | 1:50f0c5749724 | 11 | #define FREQ 100000 |
SK_ROBO_ | 1:50f0c5749724 | 12 | |
SK_ROBO_ | 1:50f0c5749724 | 13 | TextLCD lcd(PB_0, PB_1, PA_12, PF_0, PF_1, PA_8, TextLCD::LCD20x2); // rs, e, d4-d7 |
SK_ROBO_ | 1:50f0c5749724 | 14 | |
SK_ROBO_ | 1:50f0c5749724 | 15 | CMCP320x_SPI mcp3204(MOSI, MISO, CLK, CS, CHIPFAMILLY, FREQ); |
SK_ROBO_ | 1:50f0c5749724 | 16 | |
SK_ROBO_ | 1:50f0c5749724 | 17 | int main() |
SK_ROBO_ | 1:50f0c5749724 | 18 | { |
SK_ROBO_ | 0:55aac36c4f0f | 19 | // notify the user that we are starting with the ADC communication |
SK_ROBO_ | 1:50f0c5749724 | 20 | printf("Starting ADC interaction\n"); |
SK_ROBO_ | 1:50f0c5749724 | 21 | |
SK_ROBO_ | 0:55aac36c4f0f | 22 | // lets just do this forever |
SK_ROBO_ | 0:55aac36c4f0f | 23 | while (1) { |
SK_ROBO_ | 1:50f0c5749724 | 24 | //lcd.cls(); |
SK_ROBO_ | 1:50f0c5749724 | 25 | lcd.printf("CH0:%3.2f[deg]\n", mcp3204.Read(CMCP320x_SPI::CH0)/*/ 4095.0f*270.0f */); |
SK_ROBO_ | 1:50f0c5749724 | 26 | lcd.printf("CH1:%3.2f[deg]\n", mcp3204.Read(CMCP320x_SPI::CH1)/*/ 4095.0f*270.0f */); |
SK_ROBO_ | 0:55aac36c4f0f | 27 | // delay some time before reading again |
SK_ROBO_ | 1:50f0c5749724 | 28 | wait(0.5); |
SK_ROBO_ | 1:50f0c5749724 | 29 | lcd.printf("CH2:%3.2f[deg]\n", mcp3204.Read(CMCP320x_SPI::CH2)/*/ 4095.0f*270.0f */); |
SK_ROBO_ | 1:50f0c5749724 | 30 | lcd.printf("CH3:%3.2f[deg]\n", mcp3204.Read(CMCP320x_SPI::CH3)/*/ 4095.0f*270.0f */); |
SK_ROBO_ | 1:50f0c5749724 | 31 | // delay some time before reading again |
SK_ROBO_ | 1:50f0c5749724 | 32 | wait(0.5); |
SK_ROBO_ | 0:55aac36c4f0f | 33 | } |
SK_ROBO_ | 0:55aac36c4f0f | 34 | } |