View previous topic :: View next topic |
Author |
Message |
Inkwaterman
Joined: 28 Apr 2004 Posts: 14
|
Burr-Brown ads1211 |
Posted: Wed Apr 28, 2004 2:42 am |
|
|
Hi to everybody !
I try to use the A/D in the subject with a Pic microcontroller, but I have some problem with the serial comunication.
Someone had just use this IC ?
Thanx |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Wed Apr 28, 2004 3:02 am |
|
|
Give us more information about the PIC you are using and your setup, and post your code. |
|
|
Inkwaterman
Joined: 28 Apr 2004 Posts: 14
|
|
Posted: Wed Apr 28, 2004 3:28 am |
|
|
I use a Pic 18f252 and these are my routine for write ad read through the SPI:
void write_spi(byte data)
{
byte i;
for(i=0; i<8; i++)
{
output_high(PIN_C3);
delay_us(10);
if(bit_test(data,7)) output_high(PIN_C5);
else output_low(PIN_C5);
output_low(PIN_C3);
delay_us(10);
data <<= 1;
}
delay_ms(11);
}
BYTE read_spi()
{
byte i, data=0;
delay_us(10);
for(i=0; i<8;i++)
{
output_high(PIN_C3);
delay_us(10);
if(input(PIN_C5)) bit_set(data, i);
output_low(PIN_C3);
delay_us(10);
}
return(data);
}
I found, in one example for jar compiler, a reset routine for the serial communication. I try to use it but the problems remains.
This is the reset routine (I'm sorry for the unpolite code ; ) ):
void reset_ADS()
{
output_high(PIN_C3);
delay_us(10);
output_low(PIN_C3);
delay_us(10);
output_high(PIN_C3);
delay_us(10);
output_low(PIN_C3);
delay_us(10);
output_high(PIN_C3);
delay_us(10);
output_low(PIN_C3);
delay_us(10);
output_high(PIN_C3);
delay_us(10);
output_low(PIN_C3);
delay_us(10);
output_high(PIN_C3);
delay_us(10);
output_low(PIN_C3);
delay_us(10);
delay_ms(100);
}
Regard |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Wed Apr 28, 2004 7:51 am |
|
|
You should read the manual/help file reguarding the commands shift right and shift left. Performing a bit test/set with a variable bit location is a very dificult task to generate assembly code for. The compiler can do it but it's not efficient. The examples in the manual/help file are just what you need. |
|
|
|