need help in correcting errors urgently - diyAudio
Go Back   Home > Forums > Design & Build > Parts

Parts Where to get, and how to make the best bits. PCB's, caps, transformers, etc.

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 9th February 2006, 02:22 AM   #1
weifeng is offline weifeng  Singapore
diyAudio Member
 
Join Date: Feb 2006
Location: north
Default need help in correcting errors urgently

hi,

i m working on a DS1307 RTC program. i am using MPLAB IDE/C18 compiler. while trying to build the program, there are errors in it. can anyone help mi with the errors? i nid to get it done soon... the line in red is a syntax error...thanx

#define DS1307_SDA PIN_B1
#define DS1307_SCL PIN_B0
void boot_up(void);
void rtc_programming(void);
void read_rtc(void);

//==========================
// initial DS1307
//==========================
void init_DS1307()
{
output_float(DS1307_SCL);
output_float(DS1307_SDA);
}
//==========================
// write data one byte to
// DS1307
//==========================
void rtc_set(unsigned char rtcreg)
{
short int status;
i2c_start();
i2c_write(0xd0);
i2c_write(address);
i2c_write(data);
i2c_stop();
i2c_start();
status=i2c_write(0xd0);
while(status==1)
{
i2c_start();
status=i2c_write(0xd0);
}
}
//==========================
// read data one byte from DS1307
//==========================
byte read_DS1307(byte address)
{
byte data;
i2c_start();
i2c_write(0xd0);
i2c_write(address);
i2c_start();
i2c_write(0xd1);
data=i2c_read(0);
i2c_stop();
return(data);
}
  Reply With Quote
Old 9th February 2006, 09:31 AM   #2
Tom2 is offline Tom2  United States
diyAudio Member
 
Join Date: Jun 2004
Location: Central CA
I am guessing.
It has been a long time since I wrote a C program.
I looked up the MPLab C18 Compilier Users Guide.

The word "byte" is not an integer data type.
Use "unsigned char". (0-255)

Tom
  Reply With Quote
Old 10th February 2006, 07:38 AM   #3
weifeng is offline weifeng  Singapore
diyAudio Member
 
Join Date: Feb 2006
Location: north
hi,

i've alreadi tried using unsigned char, but still the same syntax error cums out.
  Reply With Quote
Old 10th February 2006, 10:35 AM   #4
Tom2 is offline Tom2  United States
diyAudio Member
 
Join Date: Jun 2004
Location: Central CA
In the previous function void rtc_set(unsigned char rtcreg)
you use the variable names "address" and "data". The variable names are not defined and values are not assigned to them. Are they then global variables?
If the variable name "address" is a global variable then using it
as a variable name in your problem function might give you problems.???

Also in the function void rtc_set(unsigned char rtcreg) ,
the variable rtcreg is not used???

Are the names "address or data" reserved words?

I'm out of ideas. Back to power jfets.

Tom
  Reply With Quote
Old 13th February 2006, 01:10 AM   #5
weifeng is offline weifeng  Singapore
diyAudio Member
 
Join Date: Feb 2006
Location: north
hi,

thanx for ur help.
but i duno hw to define the address and data...
  Reply With Quote
Old 13th February 2006, 01:54 AM   #6
diyAudio Member
 
Sparhawk's Avatar
 
Join Date: Sep 2002
Location: Ontario, Canada
As has been already mentioned, check that the word "address" isn't a reserved word. Also, I don't see a prototype for the read_DS1307 function.

I've never used the MPLab compiler, though.
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Yamaha NS-1000 Tweeters Wanted Urgently hugomac Multi-Way 33 20th December 2013 07:19 PM
My first LM3886 project (please help urgently!!) Derfla Chip Amps 13 20th March 2008 03:08 PM
Help Needed on ADC Urgently!!! wernchern Analogue Source 0 28th June 2004 04:00 AM


New To Site? Need Help?

All times are GMT. The time now is 12:19 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2