Versuche den MCP3551 am Arduino zum Laufen zu bringen.
1 | /*
|
2 | pins:
|
3 | cs=8
|
4 | sdo/rdy=12
|
5 | sck=13
|
6 | */
|
7 |
|
8 | #include <SPI.h>
|
9 |
|
10 | unsigned char sspin = 8; //cs pin
|
11 |
|
12 | union {
|
13 | int32_t value;
|
14 | uint8_t aa[4];
|
15 | } c;
|
16 |
|
17 |
|
18 | void setup(void) {
|
19 | pinMode(12, INPUT); //to check ready pin
|
20 | pinMode(sspin, OUTPUT);
|
21 | pinMode(13, OUTPUT);
|
22 | digitalWrite(sspin, HIGH);//for single conversion
|
23 | //SPI.begin();
|
24 | //SPI.setBitOrder(MSBFIRST);
|
25 | //SPI.setDataMode(SPI_MODE3);
|
26 | //SPI.setClockDivider(SPI_CLOCK_DIV16);//max. speed of chip is 5 Mhz
|
27 | Serial.begin(9600);
|
28 | Serial.println("start");
|
29 | }
|
30 |
|
31 | void loop(void) {
|
32 | digitalWrite(9, HIGH);
|
33 | while(1)
|
34 | {
|
35 | if(Serial.available())
|
36 | {
|
37 | byte rx = Serial.read();
|
38 | if(rx=='l')
|
39 | {
|
40 | digitalWrite(sspin, LOW);
|
41 | delay(5);
|
42 | digitalWrite(sspin, HIGH);
|
43 | delay(5);
|
44 | digitalWrite(sspin, LOW);
|
45 | delay(5);
|
46 | for(int i=0; i<24; i++)
|
47 | {
|
48 | Serial.println("t");
|
49 |
|
50 | digitalWrite(9, LOW);
|
51 | delay(100);
|
52 | digitalWrite(9, HIGH);
|
53 | delay(100);
|
54 | }
|
55 | }
|
56 | else
|
57 | digitalWrite(sspin, HIGH);
|
58 | }
|
59 | }
|
60 |
|
61 | }
|
Müsste doch normalerweise beim SDO/RDY Pin eine Änderung von High nach
Low sehen wenn ich die CS Leitung low ziehe, oder?
Kann mir da jemand helfen?