UECIDE error on RTC code

Post Reply
ajitnayak
Posts: 59
Joined: Mon Nov 19, 2012 9:21 am
Location: Bangalore
Contact:

UECIDE error on RTC code

Post by ajitnayak » Mon Apr 28, 2014 8:16 am

Here i am trying to upload below code. I am getting below error . let me know what i need to do.


UECIDE v0.8.4.d version i am using
R3.JPG
R3.JPG (84.36 KiB) Viewed 724 times
RTC error.JPG
RTC error.JPG (74.48 KiB) Viewed 724 times

Code: Select all


#include "Wire.h"
#define DS1307_ADDRESS 0x68
byte zero = 0x00; //workaround for issue #527

byte decToBcd(byte val){
	// Convert normal decimal numbers to binary coded decimal
	return ( (val/10*16) + (val%10) );
}

byte bcdToDec(byte val)  {
	// Convert binary coded decimal to normal decimal numbers
	return ( (val/16*10) + (val%16) );
}


void setDateTime(){

	byte second =  45; //0-59
	byte minute =11; //0-59
	byte hour = 10; //0-23
	byte weekDay =2; //1-7
	byte monthDay =23; //1-31
	byte month = 03; //1-12
	byte year  =       14; //0-99

	Wire.beginTransmission(DS1307_ADDRESS);
	Wire.send(zero); //stop Oscillator

	Wire.send(decToBcd(second));
	Wire.send(decToBcd(minute));
	Wire.send(decToBcd(hour));
	Wire.send(decToBcd(weekDay));
	Wire.send(decToBcd(monthDay));
	Wire.send(decToBcd(month));
	Wire.send(decToBcd(year));

	Wire.send(zero); //start

	Wire.endTransmission();

}



void printDate(){

	// Reset the register pointer
	Wire.beginTransmission(DS1307_ADDRESS);
	Wire.send(zero);
	Wire.endTransmission();

	Wire.requestFrom(DS1307_ADDRESS, 7);

	int second = bcdToDec(Wire.receive());
	int minute = bcdToDec(Wire.receive());
	int hour = bcdToDec(Wire.receive() & 0b111111); //24 hour time
	int weekDay = bcdToDec(Wire.receive()); //0-6 -> sunday - Saturday
	int monthDay = bcdToDec(Wire.receive());
	int month = bcdToDec(Wire.receive());
	int year = bcdToDec(Wire.receive());

	/*  int second = 11;
	 int minute =18;
	 int hour = 18;
	 int weekDay = 1;
	 int monthDay = 2;
	 int month = 11;
	 int year = 12;
	 */
	//print the date EG   3/1/11 23:59:59
	Serial.print(monthDay);
	Serial.print("/");


	Serial.print(month);
	Serial.print("/");

	Serial.print(year);
	Serial.print(" ");
	Serial.print(hour);
	Serial.print(":");
	Serial.print(minute);
	Serial.print(":");
	Serial.println(second);

	// Serial.print("Week Day Of week");
	//  Serial.println(weekDay);


}


void setup(){
	Wire.begin();
	Serial.begin(9600);
	setDateTime(); //MUST CONFIGURE IN FUNCTION
}

void loop(){
	printDate();
	delay(1000);
}










With Warm Regards

AMPS

Post Reply