|
|||||||
| Home | Forums | Rules | Articles | Store | Gallery | Blogs | Register | Donations | FAQ | Calendar | Search | Today's Posts | Mark Forums Read | Search |
| 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 |
|
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
diyAudio Member
Join Date: Feb 2006
Location: north
|
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); }
|
|
|
|
|
#2 |
|
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 |
|
|
|
|
#3 |
|
diyAudio Member
Join Date: Feb 2006
Location: north
|
hi,
i've alreadi tried using unsigned char, but still the same syntax error cums out.
|
|
|
|
|
#4 |
|
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 |
|
|
|
|
#5 |
|
diyAudio Member
Join Date: Feb 2006
Location: north
|
hi,
thanx for ur help. but i duno hw to define the address and data...
|
|
|
|
|
#6 |
|
diyAudio Member
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. |
|
|
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Yamaha NS-1000 Tweeters Wanted Urgently | hugomac | Multi-Way | 29 | 9th February 2012 11:37 AM |
| 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? |
| Page generated in 0.08597 seconds (72.30% PHP - 27.70% MySQL) with 10 queries |