Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error in reading RTC help

Status
Not open for further replies.

GrandAlf

Advanced Member level 2
Joined
Mar 9, 2002
Messages
520
Helped
47
Reputation
92
Reaction score
6
Trophy points
1,298
Location
UK
Activity points
4,730
sbit acc7

I would very much appreciate if someone can check out the following for me. Cannot seem to spot it. Get the error "too many actual parameters" DS1302GetAll, when calling time. Many thanks.

/////////////////////////////////////////////////////////////////////////////////////////
void Time()
{
unsigned char Second,Minute,Hour,Date,Month,Week,Year;

DS1302Init();
lcd_init();

lcd_puts('\f');

DS1302GetAll(Second,Minute,Hour,Date,Month,Week,Year);

printf (lcd_puts,"%02u/%02u/%02u%02u:%02u",Date,Month,Year,Hour,Minute);
printf("Date%02u/%02u/%02u\n\rTime%02u:%02u\n\r",Date,Month,Year,Hour,Minute);
DelayMs(250);
}
////////////////////////////////////////////////////////////////////////////////////////

//DS1302.h

#ifndef DS1302_H
#define DS1302_H

#include <AT89S8253.h>
#include <intrins.h>

sbit DS1302Sclk = P0^0;
sbit DS1302Io = P0^1;
sbit DS1302Ce = P0^2;

sbit ACC0 = ACC^0;
sbit ACC7 = ACC^7;

typedef struct __SYSTEMTIME__
{
unsigned char Second;
unsigned char Minute;
unsigned char Hour;
unsigned char Date;
unsigned char Month;
unsigned char Week;
unsigned char Year;
}
SYSTEMTIME;


//Register address to read and write the definition of the macro
#define SEC_WRITE 0x80
#define SEC_READ 0x81
#define MIN_WRITE 0x82
#define MIN_READ 0x83
#define HOUR_WRITE 0x84
#define HOUR_READ 0x85
#define DATE_WRITE 0x86
#define DATE_READ 0x87
#define MONTH_WRITE 0x88
#define MONTH_READ 0x89
#define WEEK_WRITE 0x8a
#define WEEK_READ 0x8b
#define YEAR_WRITE 0x8c
#define YEAR_READ 0x8d
#define WP_WRITE 0x8e
#define WP_READ 0x8f
#define TCS_WRITE 0x90
#define TCS_READ 0x91
//RAM read and write the address of the macro definition, this address tag used to preserve initialization.
#define SET_FLAG_WRITE 0xc0
#define SET_FLAG_READ 0xc1
//RAM Burst Mode in order to read and write the word
#define RAM_BURST_WRITE 0xfe
#define RAM_BURST_READ 0xff
//Burst Mode Register command to read and write the word
#define CLOCK_BURST_WRITE 0xbe
#define CLOCK_BURST_READ 0xbf
//Write-protect settings
#define WP_ON 0x80
#define WP_OFF 0x00
//Macro definition: DS1302 has been initialized.
#define IS_SET 0xAA
#define NOT_SET 0x00
//Of CE, IO, SCLK line operation of the macro definition of the purpose of doing so are a platform for future transfer to other convenience, but, when
//The pin number of the design time, it can take to do it?
#define SETB_DS1302_CE(); DS1302Ce = 1;
#define CLR_DS1302_CE(); DS1302Ce = 0;
#define SETB_DS1302_SCLK(); DS1302Sclk = 1;
#define CLR_DS1302_SCLK(); DS1302Sclk = 0;
#define PUT_DS1302_IO(); DS1302Io = ACC0;
#define GET_DS1302_IO(); ACC7 = DS1302Io;

//Function definition
extern void DS1302Init(void);
extern void DS1302WriteByte(unsigned char Data);
extern unsigned char DS1302ReadByte(void);
extern void DS1302SetWP(unsigned char Flag);
extern void DS1302GetAll(SYSTEMTIME *Time);
extern void DS1302SetAll(SYSTEMTIME *Time);
#endif


//DS1302.c

#include "DS1302.h"

void DS1302Init(void)
{
unsigned char Flag;
SYSTEMTIME TimeInit;

SETB_DS1302_CE();
DS1302SetWP(WP_OFF);
DS1302WriteByte(SET_FLAG_READ);
Flag = DS1302ReadByte();

if (Flag != IS_SET)
{
DS1302WriteByte(SET_FLAG_WRITE); //RAM 0xaa, DS1302WriteByte (SET_FLAG_WRITE); / / in the RAM in the first byte write 0xaa, that has been initialized.
DS1302WriteByte(IS_SET);
TimeInit.Second = 0x00; //TimeInit.Second = 0x00; / / initialization time.
TimeInit.Minute = 0x00;
TimeInit.Hour = 0x00;
TimeInit.Date = 0x12;
TimeInit.Month = 0x03;
TimeInit.Week = 0x06;
TimeInit.Year = 0x09;
DS1302SetAll(&TimeInit);
}
DS1302SetWP(WP_ON); //DS1302SetWP (WP_ON); / / open a write-protected.
CLR_DS1302_CE(); //CE?,DS1302 CLR_DS1302_CE (); / / release CE line, in order to avoid misoperation of the DS1302.
}

void DS1302SetWP(unsigned char Flag)
{
DS1302WriteByte(WP_WRITE); // DS1302WriteByte (WP_WRITE); / / write the word order.
DS1302WriteByte(Flag); // DS1302WriteByte (Flag); / / write the contents of registers.
}

void DS1302WriteByte(unsigned char Data)
{
unsigned char i;
ACC = Data;
for (i=8;i>0;i--) //ACC,SCLK,ACC for (i = 8; i> 0; i -) / / each write a minimum of ACC, and then sent on a SCLK is pulsed, ACC shifted to right for each one.
{
CLR_DS1302_SCLK();
PUT_DS1302_IO();
SETB_DS1302_SCLK();
ACC = ACC >> 1;
}
CLR_DS1302_SCLK(); //, CLR_DS1302_SCLK (); / / the negative hopping are read in order to prepare the next byte, and
//Do not know why, if the statement read into the next function, on how not right.
}

unsigned char DS1302ReadByte(void)
{
unsigned char i;
for(i=8; i>0; i--) //IOACC,ACC?? for (i = 8; i> 0; i -) / / Add after each IO to read the highest ACC, then sending a negative jump, read the next, each ACC is also
//Shifted to right one.
{
ACC = ACC >>1;
GET_DS1302_IO();
SETB_DS1302_SCLK();
CLR_DS1302_SCLK();
}
return(ACC);
}

void DS1302SetAll(SYSTEMTIME *Time)
{
SETB_DS1302_CE(); //CE,DS1302 SETB_DS1302_CE (); / / raises CE line, the DS1302 is ready to operate.
DS1302SetWP(WP_OFF); //DS1302SetWP (WP_OFF); / / turn off write-protected.
CLR_DS1302_CE(); //CE,DS1302 CLR_DS1302_CE (); / / release CE line, in order to avoid misoperation of the DS1302.

SETB_DS1302_CE(); //CE,DS1302 SETB_DS1302_CE (); / / raises CE line, the DS1302 is ready to operate.
DS1302WriteByte(CLOCK_BURST_WRITE); //Burst Mode Write DS1302WriteByte (CLOCK_BURST_WRITE); / / enter Burst Mode Write.
DS1302WriteByte(Time->Second);
DS1302WriteByte(Time->Minute);
DS1302WriteByte(Time->Hour);
DS1302WriteByte(Time->Date);
DS1302WriteByte(Time->Month);
DS1302WriteByte(Time->Week);
DS1302WriteByte(Time->Year);
DS1302SetWP(WP_ON); //DS1302SetWP (WP_ON); / / open a write-protected.
CLR_DS1302_CE(); //CE,DS1302???? CLR_DS1302_CE (); / / release CE line, in order to avoid misoperation of the DS1302.
}

void DS1302GetAll(SYSTEMTIME *Time)
{
SETB_DS1302_CE(); //CE,DS1302 SETB_DS1302_CE (); / / raises CE line, the DS1302 is ready to operate.
DS1302WriteByte(CLOCK_BURST_READ); //Burst Mode Read? DS1302WriteByte (CLOCK_BURST_READ); / / enter Burst Mode Read.
Time->Second = DS1302ReadByte();
Time->Minute = DS1302ReadByte();
Time->Hour = DS1302ReadByte();
Time->Date = DS1302ReadByte();
Time->Month = DS1302ReadByte();
Time->Week = DS1302ReadByte();
Time->Year = DS1302ReadByte();
CLR_DS1302_CE(); //CE?,DS1302 CLR_DS1302_CE (); / / release CE line, in order to avoid misoperation of the DS1302.
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top