gianni_pancrazi
Joined: 13 Feb 2007 Posts: 4
|
AD7691 Driver |
Posted: Wed Feb 21, 2007 10:40 am |
|
|
At the end I managed to realize it...
I'm using a 4 wire bus, with CS.
Code: |
#include<Header.h>
#device *=16
#use delay(clock=16000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#define SDI PIN_B4
#define SDO PIN_C5 // the pin description is PIC oriented
#define SCKL PIN_C3
#define CNV PIN_A4
#define LED PIN_B2
int32 data=0;
int i;
void main()
{
unsigned long cnt=0;
while(1)
{
output_high(SDO);
output_high(CNV); /* Starting conversion */
output_low(SDO);
delay_us(15);
/* Conversion Ended */
for(i=19;i>0;--i)
// for(i=32;i>13;--i)
{
output_low(SCKL);
output_high(SCKL);
shift_left(&data,3,input(SDI)); /* maybe 1 instead of 3???*/
// bit_set(data, i)
// this function is too slow to be used in the application...
}
output_high(SDO);
output_low(CNV);
cnt ++;
if (cnt==10000)
{
// printf("\r the acquired value is: %x", data);
printf("%x", data);
data=0;
output_toggle(LED); /* Blinking LED for debugging*/
cnt=0;
}
} ;
} // main() END |
I will happy if anybody of u has comments/suggestions... |
|