CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

6629 temp chip with 16f874

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Walterw
Guest







6629 temp chip with 16f874
PostPosted: Tue Jul 10, 2007 2:33 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 10, 2007 5:39 pm     Reply with quote

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
PostPosted: Wed Jul 11, 2007 5:43 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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