is this code right for ds1620

hai evryone, itz me again, i have written some code to activate ds1620, still it is not working. actually this code doesnt show the temperature readings, but it will just check weather some signal is comming from ds1620. so if any one can spare for 5 mins please have a look and suggest me where the problem is and why iam not able to get the ouput.

/*ds1260.c iam using pic 16f876 which has two 7 segment led displays*/ #include #device 16F876 ICD=TRUE #use delay(clock=4000000) #fuses XT,NOWDT, NOPROTECT, NOPUT, NOBROWNOUT #define led_delay 500 #define digitbit 49 /* for left display LB0 = (8x6)+1 */ #define digitbit1 48 /* for right display RB0 = (8x6)+0 */ #define clk_c0 56 /* portc 0 bit */ #define rst_c1 57 /* portc 1 bit */ #define ip_c5 61 /* portc 5 bit the i/p of ds1620 is been connected to 5th pin of pic*/ #define input 0xff #define output 0x00 #define port_c 0x07 /*#define temp 0x22, i havent defined temp variable it automatically taking 22h for temp, so the below tempmsb has been caluculated like 22*

8+7=183*/ #define tempmsb 183 #define config 0x0c #define valbit 176 /* here the 22 byte 0th bit same as above*/ #define seg7zero 0x3f #define seg7one 0x06 #define rstdelay 5

/* write function*/

void write_ds1620(byte adrs) { byte i; int value; for(i=0; i>1; value=adrs&0x01; if(value==0x01) { output_high(ip_c5); } else output_low(ip_c5); output_high(clk_c0); delay_us(1); } delay_us(rstdelay); } void main() { while(1) { byte rawtemp,temp=0x02; int i; int cnt = 0; set_tris_c(0xdc); /*11011100*/ delay_us(rstdelay); output_high(rst_c1); write_ds1620(config); write_ds1620(0x02); write_ds1620(0xee); write_ds1620(0xaa); output_low(rst_c1);

set_tris_c(0x20); /* reading from ds 1620*/ output_high(rst_c1); for(i=0; i

Reply to
balu
Loading thread data ...

[...]

Please put the source-code in a place where the indentation does not screw up. It's horrible to read/debug unindented code.

--
Rikard Bosnjakovic
Reply to
Rikard Bosnjakovic

"balu" schreef in bericht news: snipped-for-privacy@g14g2000cwa.googlegroups.com...

^^^ this line should not be here, you lose the LSB before you transmitted it. Place it.....

here....

Jeroen

Reply to
Jeroen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.