|
|
View previous topic :: View next topic |
Author |
Message |
Walterw Guest
|
6629 temp chip with 16f874 |
Posted: Tue Jul 10, 2007 2:33 pm |
|
|
We are trying to talk with a maxim_IC 6629 temp sensor. The connection is on port E. I can see E0 changing on the scope but the code always reads 0. After looking at the datasheet again, I noticed that we might have to set the ADCON1 = 2 but not sure how to set ADCON1 register with the CCS compiler. Am I correct in assuming that port E needs to be set to digital I/O before this will work? I have tried just setting RE0 to 1 using the output_high command, but it wont change. I did notice that if I change RE2 it also affects RE0 and RE1. It seems the chip is not in the correct mode, but not sure how to change it since we are new to the CCS compiler.
Thanks in advance!
; PORT E
; RE.0 in SDO Temperature Chip
; RE.1 out SCK Temperature Chip
; RE.2 out CS~ Temperature Chip
void ReadTemperature(void)
{
int8 i;
BYTE ddat;
set_tris_e(0x01);
output_high(PIN_E2);
output_low(PIN_E2);
ddat=0;
for (i=16;i>0;i--)
{
output_high(PIN_E1);
output_low(PIN_E1);
if (input_state(PIN_E0))
bit_set(ddat,(i-1));
}
output_high(PIN_E2);
sprintf(dmesg,"t:0x%02x",ddat);
fputs(dmesg,PC);
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 10, 2007 5:39 pm |
|
|
Look at the CCS driver file AD7715.c, for an example of how to read
16 bits from an ADC chip that has a 3-wire interface. Specifically, look
at the read_adc_word() function.
Also look at adc_init() where \CS and CLK are set to appropriate initial
values. Look at the MAX6629 data sheet to see what these levels are.
The AD7715 is more complex than your ADC chip. It has a Reset pin
and a Data Input pin. The Maxim chip doesn't have those, so you can
ignore the code that refers to those signals in the AD7715 driver.
Look closely at the MAX6629 data sheet, in which it says \CS must
remain high for a minimum of 300 ms between consecutive read operations.
Also notice in the AD7715.c file, that symbolic names are used for the
interface pins such as ADC_CLK, ADC_DO, etc. They are created with
#define statements at the top of the file. Then notice that the code in
the driver routines uses these names, instead of the pin names.
It's much better to write code this way than the way you're doing it.
Then if you change the hardware connections, you can easily update
the driver by changing the #define statements at the top of the file. |
|
|
Walterw Guest
|
6629 temp chip with 16f874 |
Posted: Wed Jul 11, 2007 5:43 am |
|
|
We ended up finding the problem.
This code was needed to set port E as digital.
setup_adc_ports(AN0_AN1_AN2_AN3_AN4);
after that it worked fine.
Thanks. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|