Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC2741_production_test.ino
Go to the documentation of this file.
1 /*
2 DC2741 production program test
3 
4 This program will run through a battery of tests to verify DC2741 connectivity.
5 Test Jig consists of an SDP breakout board (Part Number ADZS-BRKOUT-EX3)
6 
7 With the following direct connections:
8 43 - 45, 10k pulldown (IO2 - AD0)
9 44 - 47, 10k pulldown (IO4 - AD2)
10 76 - 78, 10k pulldown (IO3~ - AD1)
11 74 - 77, 10k pulldown (AD3 - IO5~)
12 
13 And the following connections with BAT85 Schottky diodes:
14 82 - 83 (SCK ->|- MOSI)
15 84 - 83 (MOSI ->|- MISO)
16 84 - 83 (CS ->|- MISO)
17 
18 **********************************************
19 IMPORTANT Note: When testing Assembly Type B,
20 R44 on the Linduino must be removed. Keep this
21 Linduino set aside, or re-install R44.
22 **********************************************
23 
24 Copyright 2018(c) Analog Devices, Inc.
25 
26 All rights reserved.
27 
28 Redistribution and use in source and binary forms, with or without
29 modification, are permitted provided that the following conditions are met:
30  - Redistributions of source code must retain the above copyright
31  notice, this list of conditions and the following disclaimer.
32  - Redistributions in binary form must reproduce the above copyright
33  notice, this list of conditions and the following disclaimer in
34  the documentation and/or other materials provided with the
35  distribution.
36  - Neither the name of Analog Devices, Inc. nor the names of its
37  contributors may be used to endorse or promote products derived
38  from this software without specific prior written permission.
39  - The use of this software may or may not infringe the patent rights
40  of one or more patent holders. This license does not release you
41  from the requirement that you obtain separate licenses from these
42  patent holders to use this software.
43  - Use of the software either in source or binary form, must be run
44  on or directly connected to an Analog Devices Inc. component.
45 
46 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
47 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
48 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
49 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
50 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
52 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
53 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56  */
57 
58 // set I2C frequency in kHz
59 #define SW_I2C_FREQUENCY 400
60 
61 #include <Arduino.h>
62 #include <stdint.h>
63 #include "LT_I2C.h"
64 #include "LT_SPI.h"
65 #include "QuikEval_EEPROM.h"
66 #include "UserInterface.h"
67 #include "Linduino.h"
68 
69 // String descriptions for each test:
70 char* descr[] = {"SCK - MISO", "MOSI - MISO", "CS - MISO", "IO2 - AD0", "IO3~ - AD1", "IO4 - AD2", "IO5 - AD3"};
71 // descr[0] = "SCK - MISO";
72 // descr[1] = "MOSI - MISO";
73 // descr[2] = "CS - MISO";
74 // descr[3] = "IO2 - AD0";
75 // descr[4] = "IO3~ - AD1";
76 // descr[5] = "IO4 - AD2";
77 // descr[6] = "IO5 - AD3";
78 
79 const uint8_t stimulus[7] = {13, 11, QUIKEVAL_CS, 2, 3, 4, 5};
80 const uint8_t readback[7] = {12, 12, 12 , 0, 1, 2, 3};
81 
83 // Print the title block
84 {
85  Serial.println("");
86  Serial.println("*****************************************************************");
87  Serial.println("* DC2741 production program test *");
88  Serial.println("* *");
89  Serial.println("* Set the baud rate to 115200 select the newline terminator. *");
90  Serial.println("* *");
91  Serial.println("*****************************************************************");
92 }
93 
94 void setup()
95 // Setup the hardware
96 {
97  quikeval_I2C_init(); // Enable the Software I2C
98  quikeval_I2C_connect(); // Connects to main I2C port
99  pinMode(2, INPUT); //GPIOs
100  pinMode(3, INPUT);
101  pinMode(4, INPUT);
102  pinMode(5, INPUT);
103  pinMode(12, INPUT);
104  pinMode(13, OUTPUT); //SCK
105  pinMode(11, OUTPUT); //MOSI
106  pinMode(QUIKEVAL_CS, OUTPUT); //
107  output_high(13);
108  output_high(11);
110 
111 
112  Serial.begin(115200); // Initialize the serial port to the PC
113  print_title();
114 }
115 
116 void loop()
117 {
118  unsigned char ack;
119  unsigned char address;
120  unsigned char ackaddr;
121  unsigned char ack_count;
122  unsigned char fail_count;
123  unsigned char i;
124  uint16_t voltage;
125  Serial.println("\nSend any character to start the test. (Press enter in Arduino Serial Monitor.)");
126  read_int();
127  Serial.println("Testing...");
128  delay(500); // Delay necessary to indicate to user that something's going on...
129  ack_count = 0;
130  fail_count = 0;
131  ackaddr = 0;
133  for (address = 0; address < 128; address++)
134  {
135  i2c_start();
136  ack = i2c_write(address << 1);
137  i2c_stop();
138  if (!ack)
139  {
140  ack_count++;
141  ackaddr = address;
142  Serial.print("Acknowledge received from address : 0x");
143  Serial.print(address, HEX);
144  Serial.print(" (7 bit) 0x:");
145  Serial.print(address<<1, HEX);
146  Serial.println(" (8-bit)");
147  }
148  }
149  if (ackaddr != 0x50)
150  {
151  Serial.println("Didn't find an EEPROM at address 0x50, FAIL");
152  ++fail_count;
153  }
155 
156 // First, test SPI port (digital levels only)
157  for(i=0; i<=2; i++)
158  {
159  output_low(stimulus[i]); //! 1) Pull Low
160  delay(1);
161  if(digitalRead(readback[i]) == HIGH)
162  {
163  Serial.print("Fail test low: ");
164  ++fail_count;
165  }
166  else
167  {
168  Serial.print("Pass test low: ");
169  }
170 
171  Serial.println(descr[i]);
172  output_high(stimulus[i]); //! 1) Pull High
173  delay(1);
174  if(digitalRead(readback[i]) == LOW)
175  {
176  Serial.print("Fail test high: ");
177  ++fail_count;
178  }
179  else
180  {
181  Serial.print("Pass test high: ");
182 
183  }
184  Serial.println(descr[i]);
185 
186 
187  }
188 
189 // Next, test GPIO / Analog connectivity
190  for(i=3; i<=6; i++)
191  {
192  pinMode(stimulus[i], INPUT);
193  delay(1);
194  voltage = analogRead(readback[i]);
195  Serial.print("Voltage: ");
196  Serial.println(voltage);
197  if(voltage < 512)
198  {
199  Serial.print("Fail test high: ");
200  ++fail_count;
201  }
202  else
203  {
204  Serial.print("Pass test high: ");
205 
206  }
207  Serial.println(descr[i]);
208 
209  pinMode(stimulus[i], OUTPUT);
210  output_low(stimulus[i]); //! 1) Pull Low
211  delay(1);
212  voltage = analogRead(readback[i]);
213  Serial.print("Voltage: ");
214  Serial.println(voltage);
215  if(voltage > 512)
216  {
217  Serial.print("Fail test low: ");
218  ++fail_count;
219  }
220  else
221  {
222  Serial.print("Pass test low: ");
223  }
224  Serial.println(descr[i]);
225  }
226 
227  if(fail_count == 0)
228  {
229  Serial.println("All tests PASS!!");
230  Serial.println("All tests PASS!!");
231  Serial.println("All tests PASS!!");
232  }
233  else
234  {
235  Serial.println("Board FAILS!!");
236  Serial.println("Board FAILS!!");
237  Serial.print("Error Count: ");
238  Serial.println(fail_count);
239  }
240 }
241 
242 
#define output_high(pin)
Set "pin" high.
Definition: Linduino.h:75
const uint8_t stimulus[7]
Header File for Linduino Libraries and Demo Code.
void i2c_stop()
Write stop bit to the hardware I2C port.
Definition: LT_I2C.cpp:462
int8_t i2c_start()
Write start bit to the hardware I2C port.
Definition: LT_I2C.cpp:425
static uint8_t address
Definition: DC2091A.ino:83
int8_t i2c_write(uint8_t data)
Send a data byte to hardware I2C port.
Definition: LT_I2C.cpp:470
#define output_low(pin)
Set "pin" low.
Definition: Linduino.h:72
QuikEval EEPROM Library.
char * descr[]
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
static void loop()
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
Definition: LT_SPI.cpp:138
int32_t read_int()
static void print_title()
static void setup()
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
static int i
Definition: DC2430A.ino:184
static float voltage
Definition: DC2289AA.ino:71
const uint8_t readback[7]
#define QUIKEVAL_CS
QuikEval CS pin (SPI chip select on QuikEval connector pin 6) connects to Arduino SS pin...
Definition: Linduino.h:57