View previous topic :: View next topic |
Author |
Message |
polo1984
Joined: 09 Mar 2007 Posts: 4 Location: torrejon
|
max1270 + pic16f876 |
Posted: Tue May 29, 2007 11:07 am |
|
|
Hi,
I am trying to acquire signals with the adc MAX1270, but i can´t be able to make it work.
I have seen some forums and I made this program, but the adc don´t make conversions. The program is so basic and the most probably it is wrong. What can I add or modify to make the MAX1270 and pic16f876 work??
Code: |
#include "D:\PROGRAMACION PROYECTO\PROGRAMACION\ADC\spi prueba3\spi_prueba3.h"
#define SSTRB PIN_C1
#define CS PIN_C2
#define CLK PIN_C3
#define DIN PIN_C4
#define DOUT PIN_C5
#define chan0 0b10000000 //channel 0, 0 to 5V, normal mode, internal clock mode
#define chan1 0b10011000
#define SPI_MODE_0_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_0_1 (SPI_L_TO_H)
#define SPI_MODE_1_0 (SPI_H_TO_L)
#define SPI_MODE_1_1 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
void main()
{
int8 ads_in1, ads_in2;
//setup the spi line
setup_spi(SPI_MASTER | SPI_MODE_0_0 | SPI_CLK_DIV_64);
set_tris_c(0x12); //pinC4 y C1 inputs
// TODO: USER CODE!!
output_low(CS);
delay_ms(10);
while(1)
{
//communicate with max1270
spi_write(chan0);
ads_in1=spi_read(0x00);
ads_in2=spi_read(0x00);
}
}
|
the datasheets of the adc are int he next direction:
http://datasheets.maxim-ic.com/en/ds/MAX1270-MAX1271B.pdf[/url]
This adc is very versatile and i hope that the program work correctly. If I can make the adc work I will think in change the adc.
I´m lost with this problem and I tried other configurations but I don´t configure correctly the adc.
If somebody can help me i be grahefull with him. Thanks for all and I will try other programs
regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue May 29, 2007 11:28 am |
|
|
Verify your hardware connections.
Pin C5 (SDO) on the PIC must go to the DIN pin on the Max1270.
Pin C4 (SDI) on the PIC must go to the DOUT pin on the Max1270. |
|
|
polo1984
Joined: 09 Mar 2007 Posts: 4 Location: torrejon
|
|
Posted: Wed May 30, 2007 9:17 am |
|
|
Hi,
I had connected the pin C5 to DIN of the adc and C4 to the pin DOUT when I had the test, I checked it.
Must I configure the pin C4 as an input and C5 as an output??
The next list show the connections that I have between the adc and the pic:
PIC ----> MAX1270
C2 ---->CS (PIN C6)
C3 ---->SCLK (PIN 5)
C4 <--- DOUT (PIN10)
C5 ----> DIN (PIN 7)
Regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 30, 2007 12:40 pm |
|
|
1. What about the \SHDN pin ? It must be connected to a logic high
level for the chip to operate.
2. According to the MAX1270 data sheet (on page 5), the conversion
time is 11 us max, with the internal clock. So, you can't just
start reading the data immediately, as your code is doing.
This thread is about similar problems with interfacing an SPI A/D chip:
http://www.ccsinfo.com/forum/viewtopic.php?t=28694
Here's another one, except that software SPI is used.
http://www.ccsinfo.com/forum/viewtopic.php?t=26629 |
|
|
polo1984
Joined: 09 Mar 2007 Posts: 4 Location: torrejon
|
|
Posted: Thu May 31, 2007 3:29 am |
|
|
hi,
The rest of the pins of the adc are connected as the schematic of the page 1 of the datasheets.
thanks for the comments and the links, i am going to read and I will test a new program with a delay of 20us (delay_us(20);) between the spi_write and spi_read and i will comment the results.
Regards |
|
|
polo1984
Joined: 09 Mar 2007 Posts: 4 Location: torrejon
|
|
Posted: Fri Jun 08, 2007 10:23 am |
|
|
Hi
I did the test and the adc acquire dates!! my problem was the pin SHDN\, I let it the pin without conexion. I put the delay of 20us between the spi_write and spi_read (in the program of the first post) later I saw the data on oscilloscope and works good.
Thanks for all!! |
|
|
|