Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Problem ADC 16bit with Arduino using SPI.h Library

Status
Not open for further replies.
At first observation I can see several bugs:

1-The DataBusy Routine is looping for ever...
2- I think You can not poll Data busy flag before set cs low...
3- You are reseting the chip on the loop.. I Don't know if you should

for now I suggest for you to correct the data not ready and try to see what you get .. So replace code from line 19 to line 30 with




Code C - [expand]
1
2
3
4
5
6
7
8
9
10
void DataNotReady()
{
    int ready=digitalRead(drdy);
    
    while(ready)
    {
        delayMicroseconds(1);
        ready=digitalRead(drdy);
    } 
}

 

still get no value in output now,

2- I think You can not poll Data busy flag before set cs low...
according to read and write timing diagram, you should wait for drdy low to drop the cs for reading the data
**broken link removed**

when i try to debugging the drdy bit it still giving value 1,then it means the data never been ready.
so i guess the problems is in the reading of the data or in looping drdy

Code C - [expand]
1
2
3
4
5
6
7
DataNotReady();
    digitalWrite(ss,LOW);   
    highByte = SPI.transfer(0x00);
    lowByte = SPI.transfer(0x00);
    adcValue = highByte << 8;
    adcValue = adcValue | lowByte;
    digitalWrite(ss,HIGH);

 

I think you can Set CS LOW at setup routine and let it remain low for ever, because is possible to use this adc with 3 wire only... so I suggest you to remove all the cs HIGH, and use only one CS LOW at setup in order the always have CS LOW... If it works we can figure out how to correctly use CS latter
 

i think ill just go back with your works previous code,sir,i just figure out using function here not work as i want,
its seems your new while loop code didnt work or maybe using the hardware loop that make it dont work,because i never get value when using this hardware loops.
and yes putting the cs always low still works in your previous code


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "SPI.h"
 
int ss=10;
unsigned int adcValue;
byte highByte;
byte lowByte;
 
void setup(){
  pinMode(ss, OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  Serial.begin(9600);
  digitalWrite(ss,LOW);
}
void loop()
{
  //series of commandbit    
  SPI.transfer(0x20);//command for comm reg to select ch1 and write to clock register ( dec     32)
  SPI.transfer(0xA5);//command for clock reg to set 2,4576Mhz                                  ( dec    165)
  SPI.transfer(0x10);//command for comm reg to write setup register                          (dec      16)
  SPI.transfer(0x44);//command for setup reg to self calibration,unipolar,unbuffered,     (dec      68)
  
  
 
  while(1)
  {
      char DataNotReady = 0x80;
      while(DataNotReady) // wait for end of conversion 
      {
          SPI.transfer(0x08);//command for comm reg to read  (dec   8)
          DataNotReady =SPI.transfer(0x00); // Read comm register
          DataNotReady &= 0x80;
      }
      
      
      SPI.transfer(0x38);//command for the comm to read data register for channel 1 (dec  56)
      
      //read 16bit of data ADC
      highByte = SPI.transfer(0x00);
      lowByte = SPI.transfer(0x00);
      
      adcValue = highByte << 8;
      adcValue = adcValue | lowByte;
      
      digitalWrite(ss,HIGH);
      Serial.print("analog value =");
      Serial.println(adcValue, DEC);
      Serial.print('\n');
      delay(1000);
  }
}

 

I've just remembered one more thing....

at the datasheet on page 24 is says:

The default state of the MAX1415/MAX1416 is to wait for a write to the communications register. Any write or read operation on the MAX1415/MAX1416 is a two-step process:
  • First, a command byte is written to the communications register. This command selects the input channel, the desired register for the next read or write operation, and whether the next operation is a read or a write.
  • The second step is to read from or write to the selected register. At the end of the data-transfer cycle, the device returns to the default state.
See the Performing a Conversion section for examples.

If the serial communication is lost, write 32 ones to the serial interface to return the MAX1415/MAX1416 to the default state. The registers are not reset after this operation.

In the way I see a read or write operation is both the write to comm reg, and write/read the specified reg.. In your timing diagrams, as you can see, the CS is always low in read/write operations...
**broken link removed**



This Is not always happening in your code as I will show you:

This part of the code is respecting the above statements bit you are not waiting for data... so this code will stuck here... you need the data ready pooling

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void SeriesCommandBit()
  {
  //DataNotReady(); Remove this... you are not waiting for data!
 
  digitalWrite(ss,LOW);  // CS LOW
 
  // Write Op
  SPI.transfer(0x20);//WRITE TO COM REG     - command for comm reg to select ch1 and write to clock register ( dec     32)
  SPI.transfer(0xA5);//WRITE TO 8BIT REG     -command for clock reg to set 2,4576Mhz                                  ( dec    165)
  // End of Write Op
 
  //  Write Op
  SPI.transfer(0x10);//WRITE TO COM REG     -command for comm reg to write setup register                          (dec      16)
  SPI.transfer(0x44);//WRITE TO 8BIT REG     -command for setup reg to self calibration,unipolar,unbuffered,     (dec      68)
  //  End of Write Op
 
  digitalWrite(ss,HIGH);  // CS HIGH
  }




In the next code, i think that you are not respecting the read diagram that you posted above, because you put CS HIGH between the 1st and 2nd phase of the Read operation... As result you loose the communication... For recover communication with the ADC you need to send it 32 ones (0xFFFFFFFF), and it will be back the default state of wait for read and write operations (waiting for the first phase of read or write OP)...


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
void loop()
{
   // DataNotReady(); Remove this
 
    digitalWrite(reset,LOW); // RESET LOW  ->I  don't know how to handle the reset pin
 
    digitalWrite(ss,LOW);  // CS LOW
    delay(100);
 
    digitalWrite(reset,HIGH); //Reset HIGH ->I  don't know how to handle the reset pin
 
    digitalWrite(ss,HIGH);  // CS HIGH
 
    SeriesCommandBit();   // This Sub IS correctly Handled as long you remove the wait for data pooling....
 
   // DataNotReady(); remove this
 
    digitalWrite(ss,LOW); // CS LOW
 
    // READ OP
    SPI.transfer(0x38); // WRITE TO COM REG
    delayMicroseconds(1);
    digitalWrite(ss,HIGH); // CS HIGH ->Here you violate the READ OPERATION and you LOOSE the communication 
    DataNotReady();
    digitalWrite(ss,LOW);  // CS LOW  -> removing the above cs high you can also remove this
    highByte = SPI.transfer(0x00);// READ HIGH BYTE OF WORD REG
    lowByte = SPI.transfer(0x00);// READ LOW BYTE OF WORD REG
    // END OF READ OP
 
    adcValue = highByte << 8;
    adcValue = adcValue | lowByte;
 
    digitalWrite(ss,HIGH); // CS HIGH
 
    // SEND DATA to PC
    Serial.print("analog value =");
    Serial.println(adcValue, DEC);
    Serial.print('\n');
    delay(1000);
}




About the reset pin... I think You are adding complexity to the subject... You should try to avoid using reset pin until you figure out how to handle comm...

I also suggest you to code a read data function, a write config function, and two poling functions(by hardware , and by soft... in order for you to be able to perform tests...)...

One other advice... start from a working code( for example start with I code I gave You).. Perform small changes to code, and test them to see if it works... If you want to poll the status by hardware, you should start for try changing my code for polling by hardware...

I have a few ideas on how to do it, but I'm afraid of make you loose the fun off figuring it out...

---------- Post added at 13:10 ---------- Previous post was at 12:35 ----------

....
and yes putting the cs always low still works in your previous code

In the my code there is no CS HIGH as in the code you posted on line 45

---------- Post added at 14:00 ---------- Previous post was at 13:10 ----------

Here is a version of my code with CS handling... I hope you can understand how to handle CS here... and I use the data busy pooling only before read the data...


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "SPI.h"
 
int ss=10;
unsigned int adcValue;
 
 
 
 void setup()
 {
  pinMode(ss, OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  Serial.begin(9600);
}
 
void MAX1416_Config()//You can modify it for handle channels
{
  //series of commandbit    
  digitalWrite(ss,LOW); // Enable ADC SPI
  
  //Write OP
  SPI.transfer(0x20);//command for comm reg to select ch1 and write to clock register ( dec     32)
  SPI.transfer(0xA5);//command for clock reg to set 2,4576Mhz                                  ( dec    165)
  //End Write OP
  
  //Write OP
  SPI.transfer(0x10);//command for comm reg to write setup register                          (dec      16)
  SPI.transfer(0x44);//command for setup reg to self calibration,unipolar,unbuffered,     (dec      68)
  //End Write OP
  
  digitalWrite(ss,HIGH); // Disable ADC SPI
}
 
void MAX1416_WaitForData_Soft() 
{
      char DataNotReady = 0x80;
      
      digitalWrite(ss,LOW); // Enable ADC SPI
      
      while(DataNotReady) // wait for end of conversion 
      {
          // Read OP
          SPI.transfer(0x08);//command for comm reg to read  (dec   8)
          DataNotReady =SPI.transfer(0x00); // Read comm register
          // End Read OP
          
          DataNotReady &= 0x80;
      }
      
      digitalWrite(ss,HIGH); // Disable ADC SPI
}
 
unsigned int MAX1416_ReadCH0Data() //You can modify it to read other channels
{
      unsigned int uiData;
      byte highByte;
      byte lowByte;
      
      digitalWrite(ss,LOW); // Enable ADC SPI
      
      // READ Data OPERATION
      SPI.transfer(0x38);//command for the comm to read data register for channel 1 (dec  56)
      //read 16bit of data ADC
      highByte = SPI.transfer(0x00);
      lowByte = SPI.transfer(0x00);
      // End Read Data
      
      digitalWrite(ss,HIGH); // Disable ADC SPI
    
      
      uiData = highByte << 8;
      uiData |= lowByte;
      
      return uiData;
}
 
void loop()
{
 
  MAX1416_Config();
 
  while(1)
  {
      MAX1416_WaitForData_Soft() ;
      
      adcValue = MAX1416_ReadCH0Data();
      
      Serial.print("analog value =");
      Serial.println(adcValue, DEC) );
      Serial.print('\n');
      delay(1000);
  }
}



You can include the data ready pooling in the read channel function.. that way you can reduce cs pin activity ...
Please let me know if the above code works...

Any way, with all this said, I'm pretty sure that the main reason for the your code not to be working is the underhanded use of the DRDY poling... You check DRDY only before read data...

And I still have a few doubts on the CS usage.. is possible that I miss understood the read/write MAX1416 OP with the read/write SPI OP... Any first I need to know the result of testing the code I've provided to be able to exclude the Data Ready ISSUE
 
Last edited:

thank you again mgate
your code gave reading

analog value =0

analog value =32896

analog value =32896

analog value =32896

analog value =32896

analog value =32896

analog value =32896

analog value =128

as i mentioned before 32896 is 1000 0000 which is reading in the data have not been ready,but how could this happen?since i read your code its doing fine with the right flow of datasheet said,but why the reading its still in the looping of data not ready?

and ive revised your code lil bit with the extra cs low and high in every phase of write and read,and giving delaymicroseconds to wait drdy drop only in reading phase,but the reading also still same as worked code before,
analog value =0

analog value =32639

analog value =65535

analog value =32767

analog value =65535

analog value =32639


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "SPI.h"
 
int ss=10;
unsigned int adcValue;
 
 
 
 void setup()
 {
  pinMode(ss, OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  Serial.begin(9600);
}
 
void MAX1416_Config()//You can modify it for handle channels
{
  //series of commandbit    
  digitalWrite(ss,LOW); // Enable ADC SPI
  
  //Write OP
  SPI.transfer(0x20);//command for comm reg to select ch1 and write to clock register ( dec     32)
  SPI.transfer(0xA5);//command for clock reg to set 2,4576Mhz                                  ( dec    165)
  //End Write OP
  
  //Write OP
  SPI.transfer(0x10);//command for comm reg to write setup register                          (dec      16)
  SPI.transfer(0x44);//command for setup reg to self calibration,unipolar,unbuffered,     (dec      68)
  //End Write OP
  
  digitalWrite(ss,HIGH); // Disable ADC SPI
}
 
void MAX1416_WaitForData_Soft() 
{
      char DataNotReady = 0x80;
      
      
      
      while(DataNotReady) // wait for end of conversion 
      {
          // Read OP
          digitalWrite(ss,LOW);
          SPI.transfer(0x08);//command for comm reg to read  (dec   8)
          digitalWrite(ss,HIGH);
          delayMicroseconds(1);//wait drdy low before drop cs,datasheet said its in nS
          digitalWrite(ss,LOW);
          DataNotReady =SPI.transfer(0x00); // Read comm register
          // End Read OP
          digitalWrite(ss,HIGH);
          DataNotReady &= 0x80;
      }
      
}
 
unsigned int MAX1416_ReadCH0Data() //You can modify it to read other channels
{
      unsigned int uiData;
      byte highByte;
      byte lowByte;
      
      digitalWrite(ss,LOW); // Enable ADC SPI
      
      // READ Data OPERATION
      SPI.transfer(0x38);//command for the comm to read data register for channel 1 (dec  56)
      digitalWrite(ss,HIGH);
      //read 16bit of data ADC
      delayMicroseconds(1);//wait drdy low before drop cs,datasheet said its in nS
      digitalWrite(ss,LOW);
      highByte = SPI.transfer(0x00);
      lowByte = SPI.transfer(0x00);
      // End Read Data
      
      digitalWrite(ss,HIGH); // Disable ADC SPI
    
      
      uiData = highByte << 8;
      uiData |= lowByte;
      
      return uiData;
}
 
void loop()
{
 
  MAX1416_Config();
 
  while(1)
  {
      MAX1416_WaitForData_Soft() ;
      
      adcValue = MAX1416_ReadCH0Data();
      
      Serial.print("analog value =");
      Serial.println(adcValue, DEC);
      Serial.print('\n');
      delay(1000);
  }
}




and whenever i tried with hardware pooling it wont work or the data wont be ready,
Code:
void MAX1416_WaitForData_Hard() 
{
     int DataNotReady=digitalRead(drdy);
	  
      while(DataNotReady=1) // wait for end of conversion 
      {
          DataNotReady=digitalRead(drdy);
      }
      
}
forget about the hardware pooling,lets be focus on the software pooling instead


and including MAX1416_WaitForData_Soft() function in reading ch0 also always give reading 65535,
 
Last edited:

Hi, I can only read your post better latter at night, but for now I wanted to say that there is a problem in in your hardware poling... it will loop for ever because of the while condition... Logically, a number equal to zero is false..and a number difrent from zero is true...

DataNotReady=1 is setting this var always to true befor the while test.. use : (DataNotReady==1) or simply (DataNotReady) as condition..

Code:
void MAX1416_WaitForData_Hard() 
{
     int DataNotReady=digitalRead(drdy);
	  
      while([B]DataNotReady=1[/B]) // wait for end of conversion 
      {
          DataNotReady=digitalRead(drdy);
      }
      
}

should be

Code:
void MAX1416_WaitForData_Hard() 
{
     int DataNotReady=digitalRead(drdy);
	  
      while([B]DataNotReady[/B]) // wait for end of conversion 
      {
          DataNotReady=digitalRead(drdy);
      }
      
}


I will read you previous post latter in order to understand what you achieved ..
 

I have 3 questions in order to understand it better...

First question.
Does the first code sample I posted ( the one using CS always low) returned always 32896 as the last attempt?

Second,
Are connecting reset pin to GND ? (Reset pin can not be leaved floating!)

third,
what is the voltage that you are using for testing the adc reading?

---------- Post added at 00:33 ---------- Previous post was at 00:08 ----------

Also, after reading the following posts quoted bellow:
**broken link removed**
Mickey,

I believe you are getting the SHIFTOUT frequency of the SX/B command mixed up with the CLKIN frequency stated in the data sheet. The data sheet states CLKIN is either connected to a crystal/resonator between CLKIN and CLKOUT, or with a CMOS-compatible clock source. Also, the CLKIN can be connected to GND when using the internal oscillator. This is found on page 18 of the data sheet. Also, pay attention to Note 15 on page 9. This is in reference to the CLKIN.

According to timing characteristics found on page 8, the maximum speed of the serial clock is 5 MHz (1/100nS SCLK LOW + 1/100nS SLCK HIGH). There is no minimum speed specified for the SCLK.

Gary
...................

...................
Gary,

Thanks for the clarification. I found out my problem .... I left the RESET pin floating, after I tied it to GND DRDY was going LOW like it should.
I am now in the process of using the example TX_BYTE subs with the SHIFTIN command to read the data on my terminal.

Thanks

mikey


I've started asking my self of what was your initial configuration... You are using the internal oscillator, and according to the post above you should have CLKIN connected to GND, as well as the RESET pin should be connected to GND

so according to pin configuration (attached image)
73696d1336213669t-image.png

heres my configuration:

sclk to pin 13
cs to pin 10
ain+ to 5v
ain- to gnd
ref+ to 5v
ref- to gnd
dout to pin 11
din to pin 12
vdd to 5v
gnd to gnd


thanks,

oneitusatu
 

you're really bad at this aren't you ?

When you say "dont get my reading at all" do you mean there is no output displayed ?
I think that will be so, since you have a "while (true)" loop in DataNotReady with no exit statement.
 

I have 3 questions in order to understand it better...

First question.
Does the first code sample I posted ( the one using CS always low) returned always 32896 as the last attempt?

Second,
Are connecting reset pin to GND ? (Reset pin can not be leaved floating!)

third,
what is the voltage that you are using for testing the adc reading?

---------- Post added at 00:33 ---------- Previous post was at 00:08 ----------

Also, after reading the following posts quoted bellow:
**broken link removed**



I've started asking my self of what was your initial configuration... You are using the internal oscillator, and according to the post above you should have CLKIN connected to GND, as well as the RESET pin should be connected to GND
here's my new schematic
**broken link removed**
answering ur questions
1.your code in #25 give reading
random number,and mostly give 32629,which is in binary 01111111 01111111
2.id already fix that thank you,thats my bad
3.i give 3,3volt same as reference and i am also trying it with voltage divider and the reading are not much different


you're really bad at this aren't you ?

When you say "dont get my reading at all" do you mean there is no output displayed ?
I think that will be so, since you have a "while (true)" loop in DataNotReady with no exit statement.
so where i should put the exit statement by you mean?
i thought the loops will exit by itself if statement inside parentheses goes wrong,and as long the statement still true the loops doing the statement inside curly bracket


and btw,
where i should put all these grounding?for all this time i connect the gnd to arduino gnd,
but when i give it the gnd to max1416 the result is different,but still unreliable
 
Last edited:

here's my new schematic
1.your code in #25 give reading
random number,and mostly give 32629,which is in binary 01111111 01111111

I was Asking the output for the code I've posted at post #2

so where i should put the exit statement by you mean?
i thought the loops will exit by itself if statement inside parentheses goes wrong,and as long the statement still true the loops doing the statement inside curly bracket

you was using:

Code:
....

      while(DataNotReady=1) // wait for end of conversion 
      {
          DataNotReady=digitalRead(drdy);
      }

...

and its functionality is equivalent to


Code:
...
      DataNotReady=1;
      while(DataNotReady) // wait for end of conversion 
      {
          DataNotReady=digitalRead(drdy);
          DataNotReady=1;
      }
...


after a simplification, you was using this:

Code:
...
      while(true) // wait for end of conversion 
      {
          DataNotReady=digitalRead(drdy);
      }
...

____________________________________________________________________________

you can use this code for hardware polling:
Code:
void MAX1416_WaitForData_Hard() 
{
     int DataNotReady=digitalRead(drdy);
	  
      while(DataNotReady) // wait for end of conversion 
      {
          DataNotReady=digitalRead(drdy);
      }
}


......
____________________________________________________________________________
random number,and mostly give 32629,which is in binary 01111111 01111111
.....
3.i give 3,3volt same as reference and i am also trying it with voltage divider and the reading are not much different

VREF = (VREF+) - (VREF-) = 3,3 volt - 0volt = 3,3V

1 LSB = 2 * VREF / (GAIN * (65536))

If GAIN = 1,

1 LSB = 2* 3,3 / 65536

01111111 01111111 = 32639

So reading is 32639 * 1LSB
ADC Value is (32639/65536) * 2 * 3,3 = 3,287 V meaning the reading is probably correct

---------- Post added at 20:13 ---------- Previous post was at 19:40 ----------

Also, datasheet specifications use as reference:

VDD = 5V,
GND = 0,
VREF+ = 2.5V,
VREF- = GND,
fCLKIN = 2.4576MHz,
CLKDIV bit = 0,
CREF+ to GND = 0.1μF,
CREF- to GND = 0.1μF,

but I don't have enough knowledge to know if not using this capacitors will cause bad readings ... check this example connection diagram at page 12 from **broken link removed**


Anyway I steel think that the above value is a correct reading
 
Last edited:

your code's in #2 always gives reading 65535 for measuring refference and for different value,

yes,your math is correct but its for the bipolar mode,and i use the unipolar mode,
so 1LSB=VREF/(GAIN)65536
otherwise,i hook it up with the voltage divider 4700Ω & 3300Ω it keeps give reading 32639
 

yes,your math is correct but its for the bipolar mode,and i use the unipolar mode,
so 1LSB=VREF/(GAIN)65536
otherwise,i hook it up with the voltage divider 4700Ω & 3300Ω it keeps give reading 32639
I'm sorry.. you are right.. thanks for the correction...

Anny luck with the hardware poling?

I was thinking, what if you add a 1 ms delay after each CS LOW, just before communication?
 

hardware looping still give reading of drdy 1,
so i guess there's a problem before the software/hardware looping,
ive tried to set a value to clock register and tried to read it but it give reading that the data always 1/FFFFFFFF
it means that we must be miss on something before we write/read in register with this device
any ideas for this?
 

....
i've tried to set a value to clock register and tried to read it but it give reading that the data always 1/FFFFFFFF
....

I didn't understand... 1/FFFFFFFF ???

the clock register is bidirectional ..it's size is one byte...
the power on reset value (default value) is 0x85, so the reading at start up should be 0x85... if you set clock register to such a value that sets ClockDisable bit, since you don't use an external clock source, the adc won't be able to communicate trough the SPI
 
Last edited:

yes the reading showed like that,in 4 byte
its problems in reading the data,i cant get reading default value in clock register that sould give 85 in hex
how i should write the code for reading?


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <SPI.h>
 
int ss=10;
 
unsigned int adcValue;
 
void setup(){
  pinMode(ss,OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  Serial.begin(9600);
}
 
void loop(){
  digitalWrite(ss,LOW);
  SPI.transfer(0x28);
  digitalWrite(ss,HIGH);
  delay(1);//wait for drdy drop
  digitalWrite(ss,LOW);
  char data=SPI.transfer(0x00);
  digitalWrite(ss,HIGH);
  Serial.println(data,HEX);
  delay(500);
}

 

Can you test this with cs always low?


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <SPI.h>
 
int ss=10;
 
 
void setup(){
  pinMode(ss,OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  Serial.begin(9600);
 digitalWrite(ss,LOW);
}
 
void loop(){
 
  SPI.transfer(0x28);
 
  delay(1);//wait for drdy drop
 
  char data=SPI.transfer(0x00);
 
  Serial.println(data,HEX);
  delay(500);
}



__________
ps: Today I've ordered a sample MAX1416EPE+ so that I can be able to better understand the problem ...
 
Last edited:


finally ive found my problem,its on the contact i use for adaptor from smd to breadboard,when i change it all seems fine,
and thank you mgate for sticking in this thread and give me a better understanding in SPI,ill give you 30 points :)
 

oneitusatu,
I also learned with this thread..

Thank you for the feedback!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top