avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re[avr-chat] ad data between DS1302 and ATMEGA8


From: microhead
Subject: re[avr-chat] ad data between DS1302 and ATMEGA8
Date: Sat, 31 Jan 2009 01:16:56 -0800 (PST)

Dears all, there is some fault in following procedure. Function returns value, but with same number. I check circuit with osciloskop, I put to code output about reading DS1302(LED signal), it looks good. But I´m not sure with bit shifts there. Do you have any idea what could be wrong? unsigned char read_DS1302 (unsigned char adresa) { unsigned char cc1, data; init_DS1302(); data="" RESET = 1; // start communication for (cc1=0; cc1<8; cc1++) // send command BYTE { if ((adresa&0x01) == 1) SDO = 1; else SDO = 0; adresa = adresa >> 1; // bit shift right SCLK = 0; delay_us(1); SCLK = 1; delay_us(1); SCLK=0; } SDA_M = 0; // SDA like input data = "" for (cc1=0; cc1<8;cc1++) // data transfer { SCLK = 0; delay_us(2); data = "" char)SDI; LED = !(unsigned char)SDI; data>>1; SCLK = 1; delay_us(2); } SDO =0; // end communication SCLK = 0; RESET =0; return data; }

View this message in context: read data between DS1302 and ATMEGA8
Sent from the AVR - General mailing list archive at Nabble.com.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]