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 typedef struct - Too many actual parameters

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
Error in typedef struct

Sorry have posted this again, can anyone offer any advice. Driving me crazy.

When I try and compile the following with Ke*l C51, I get the following.

Error C208 DS1302GetAll Too many actual parameters

Seems to be line in Time function

/* DS1302 RTC Drivers*/

#pragma SMALL // Small memory model
#include <AT89S8253.h>
#include <intrins.h>
#include <stdio.h>
#include "delay.h"
#include "lcd.h"

//#define ResetWD() WDTCON = WDTCON | 0x02

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

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

typedef struct __SYSTEMTIME__
{
unsigned int Second;
unsigned int Minute;
unsigned int Hour;
unsigned int Date;
unsigned int Month;
unsigned int Week;
unsigned int 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;

// Variables (Global)
char buf[16]; // LCD Display Buffer

//Prototypes
void serial_init(void);
void DS1302Init(void);
void DS1302SetWP(unsigned int Flag);
void DS1302WriteByte(unsigned int Data);
unsigned int DS1302ReadByte(void);
void DS1302SetAll(SYSTEMTIME *Time);
void DS1302GetAll(SYSTEMTIME *Time);
void Time(void);

void main(void)
{
serial_init();
lcd_init();
lcd_clear();

while(1)
{
Time();
DelayMs(255);
DelayMs(255);
DelayMs(255);
DelayMs(255);
DelayMs(255);
DelayMs(255);
DelayMs(255);
DelayMs(255);
DelayMs(255);DelayMs(255);DelayMs(255);DelayMs(255);
DelayMs(255);DelayMs(255);DelayMs(255);DelayMs(255);
DelayMs(255);DelayMs(255);DelayMs(255);DelayMs(255);
DelayMs(255);DelayMs(255);DelayMs(255);DelayMs(255);
DelayMs(255);DelayMs(255);DelayMs(255);DelayMs(255);
DelayMs(255);DelayMs(255);DelayMs(255);DelayMs(255);
}
}


/////////////////////////////////////////////////////////////////////////////
void serial_init (void)
{
TMOD = 0x20; // Timer 1 mode 2: 8-Bit reload
TH1 = 0x98; // Reload value 300 baud
SCON = 0x52; // Mode 1: 8-bit UART, enable receiver TI remains set
TR1 = 1; // Timer 1 run
ES = 0; // Disable serial port interrupt
EA = 0; // Disable

//WDTCON = WDTCON | 0xEA; // Initial Watchdog Setup 2048Ms
//WDTCON = WDTCON | 0x01; // Enable WatchDog WDTEN Set
}
/////////////////////////////////////////////////////////////////////////////
void Time(void)
{
unsigned int Second,Minute,Hour,Date,Month,Week,Year;

DS1302Init();
lcd_goto(0x00);


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


sprintf (buf," %02u/%02u/%02u% 02u:%02u",Date,Month,Year,Hour,Minute);lcd_puts(buf);
printf("Date%02u/%02u/%02u\n\rTime%02u:%02u\n\r",Date,Month,Year,Hour,Minute);
DelayMs(250);
}
////////////////////////////////////////////////////////////////////////////////////
void DS1302Init(void)
{
unsigned int 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 int Flag)
{
DS1302WriteByte(WP_WRITE); // DS1302WriteByte (WP_WRITE); / / write the word order.
DS1302WriteByte(Flag); // DS1302WriteByte (Flag); / / write the contents of registers.
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void DS1302WriteByte(unsigned int Data)
{
unsigned int 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 int DS1302ReadByte(void)
{
unsigned int 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.
}
////////////////////////////////////////////END FUNCTIONS///////////////////////////////////////////////////////////////////////
 

Error in typedef struct

Managed to get it compiled, the fault was with the following, correct version is below. However still will not access the chip, in either read or write mode. This is in Proteus simulation, not tried in in hardware as yet. Would very much appreciate if someone could glance through it, to see if I have made any obvious blunders.


void GetTime(void)

{
SYSTEMTIME systime;

lcd_goto(0x00);

DS1302GetAll ( &systime );

sprintf (
buf,
" %02u/%02u/%02u %02u:%02u",
systime.Date,
systime.Month,
systime.Year,
systime.Hour,
systime.Minute );
lcd_puts(buf);

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

Error in typedef struct

All ok now.

Decided to use DS1307 instead, I2C bus. Now works fine with different driver.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top