PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Convert
libspi_adc
MCP3202.c
1
/* Measure Volts
2
* Use Serial Peripheral Interface to communicate with
3
an MCP3202 to measure voltage across channels 0 and 1 to ground.
4
*
5
* Don't forget to double check your hardware, and post problems
6
* on the Parallax forums!
7
*
8
* Written by Andrew Enright
9
*/
10
#include "spi_adc.h"
// Include simpletools lib
11
#include "
simpletools.h
"
12
int
t_CS=26, t_clk=23, t_miso=24, t_mosi=25;
// DO = MOSI, DI = MISO
13
float
t_vref = 5.08;
14
15
int
main
()
// Main function
16
{
17
while
(1)
// Main loop
18
{
19
putchar(
CLS
);
//clear screen between updates
20
float
v0 = MCP3202_getVolts(0, t_mosi, t_miso, t_clk, t_CS, t_vref);
21
float
v1 = MCP3202_getVolts(1, t_mosi, t_miso, t_clk, t_CS, t_vref);
22
print
(
"%cCh0: %f V\nCh1: %f V\n"
,
HOME
,v0, v1);
23
pause
(500);
// Wait 0.5 s before repeat
24
}
//end while
25
}
//end main
CLS
#define CLS
CLS character (16) clears SimpleIDE's screen, erasing all characters and placing the cursor in the to...
Definition:
simpletools.h:363
HOME
#define HOME
HOME character (1) sends SimpleIDE Terminal's cursor to top-left "home" position.
Definition:
simpletools.h:233
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17