display 1234

Page 1 of 1

7 Replies - 1552 Views - Last Post: 22 March 2013 - 06:43 AM Rate Topic: -----

#1 goodluckbence  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-December 12

display 1234

Posted 16 December 2012 - 03:00 PM

Hi all,

I am doing a program to display 1234 but it just doesn't want to work.

here is the code
it say that the numbers i declared in the main program is parameter list is longer than the prototype


/*************************************************************************
* A Program for the 7-Segmen Display Module –
*************************************************************************/
#include <reg51.h>
#include <string.h>
/* Declaration of the Data and Clock Bits for the M5450 */
sbit Data = P1^4 ;
sbit Clock = P1^6 ;
//sbit Enable = ? ; /* Only on some Modules but not all */
/* A very short Delay of about 10 microseconds */
/* This doesn’t have to be accurate as explained in the lecture classes */
void M5450_Delay(void)
{
int i;
	for (i=0;i<10000; i++)
	{
		;
	}	
}
void M5450_Pulse(void)
{
/* This function sends a single clock pulse to the M5450 Driver */
Clock=0;
Clock=1;
M5450_Delay(); /* A short Delay */
Clock=0;
}
void M5450_Send (void)
{	
	int D0,D1,D2,D3;
	
/* This function sends the 8-bit (byte) D to the M5450 in serial form */
/* with the least significant bit first */
D0=0x66;
D1=0x4F;
D2=0x5B;
D3=0x06;

	}
/* The following function sends a start pulse to the M5450 */
void M5450_Start(void)
{
//Enable = 0; /* Eliminate this line if there is no Enable pin defined */
Data = 0;
M5450_Pulse();
Data = 1;
M5450_Pulse();
}
/* The Main Program */
void main (void)
{
/* Declaration of all local variables in the main part of the program */
/* First Send a Start Pulse to the M5450 */
M5450_Start();
for(;;)/>/>
{
M5450_Send(0x66);
M5450_Send(0x4F);
M5450_Send(0x5B);
M5450_Send(0x06);

/* Send a further Three Clock Pulses to Complete the 35 Pulses */
M5450_Pulse();
M5450_Pulse();
M5450_Pulse();
}

This post has been edited by Atli: 16 December 2012 - 03:06 PM
Reason for edit:: Use [code] tags when posting code.


Is This A Good Question/Topic? 0
  • +

Replies To: display 1234

#2 ihatesegfault  Icon User is offline

  • New D.I.C Head

Reputation: 17
  • View blog
  • Posts: 47
  • Joined: 24-September 12

Re: display 1234

Posted 16 December 2012 - 04:06 PM

Ok. first off, look at lines 7-8. you can't use ^ to do powers, you need to
#include <math.h>
and use pow(x,n)

Now look at line 28 and lines 57-60. You're argument list for M540_Send is void as in no arguments, but you are sending the function arguments in lines 57-60. The error message basically tells you that, because 1 argument is more than none. So decide what the argument list is going to be and stick with it.

Happy coding
Was This Post Helpful? 0
  • +
  • -

#3 jimblumberg  Icon User is offline

  • member icon


Reputation: 4133
  • View blog
  • Posts: 12,865
  • Joined: 25-December 09

Re: display 1234

Posted 16 December 2012 - 04:39 PM

Quote

Ok. first off, look at lines 7-8. you can't use ^ to do powers, you need to

If I remember correctly those lines are not trying to do powers but is a compiler specific notation that means port 1 bit 4 and port 1 bit 6. The sbit is a "single bit" and P1 is a value defined in the reg51.h header file.

The rest of your post is spot on. The function prototype, function implementation and function call must all agree as to the number and type of parameters.

Jim

This post has been edited by jimblumberg: 16 December 2012 - 04:41 PM

Was This Post Helpful? 1
  • +
  • -

#4 ihatesegfault  Icon User is offline

  • New D.I.C Head

Reputation: 17
  • View blog
  • Posts: 47
  • Joined: 24-September 12

Re: display 1234

Posted 16 December 2012 - 05:44 PM

Oops, sorry.
Was This Post Helpful? 0
  • +
  • -

#5 goodluckbence  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-December 12

Re: display 1234

Posted 17 December 2012 - 03:03 PM

Thanks, I've done it, it works now it didn't have a proper function
Thanks again
Was This Post Helpful? 0
  • +
  • -

#6 minidimi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 21-March 13

Re: display 1234

Posted 21 March 2013 - 09:30 PM

View Postgoodluckbence, on 17 December 2012 - 03:03 PM, said:

Thanks, I've done it, it works now it didn't have a proper function
Thanks again


Hey,
I am trying to do the same but its not just working.
My code is

#include <reg51.h>
#include <string.h>
/* Declaration of the Data and Clock Bits for the M5450 */
sbit Data = P1^4 ;
sbit Clock = P1^6 ;
//sbit Enable = ? ; /* Only on some Modules but not all */
/* A very short Delay of about 10 microseconds */
/* This doesn’t have to be accurate as explained in the lecture classes */
void M5450_Delay(void)
{
int i;
for (i=0;i<10000; i++)
{
;
}	
}
void M5450_Pulse(void)
{
/* This function sends a single clock pulse to the M5450 Driver */
Clock=0;
Clock=1;
M5450_Delay(); /* A short Delay */
Clock=0;
}
void M5450_Send (void)
{	
int D0,D1,D2,D3;

/* This function sends the 8-bit (byte) D to the M5450 in serial form */
/* with the least significant bit first */
D0=0x66;
D1=0x4F;
D2=0x5B;
D3=0x06;

}
/* The following function sends a start pulse to the M5450 */
void M5450_Start(void)
{
//Enable = 0; /* Eliminate this line if there is no Enable pin defined */
Data = 0;
M5450_Pulse();
Data = 1;
M5450_Pulse();
}
/* The Main Program */
void main (void)
{
/* Declaration of all local variables in the main part of the program */
/* First Send a Start Pulse to the M5450 */
M5450_Start();
for(;;)/>/>
{
M5450_Send(0x66);
M5450_Send(0x4F);
M5450_Send(0x5B);
M5450_Send(0x06);
/* Send a further Three Clock Pulses to Complete the 35 Pulses */
M5450_Pulse();
M5450_Pulse();
M5450_Pulse();
}


any help would be appreciated. I guess your code is working fine can u help me with this.
Thanks.

This post has been edited by JackOfAllTrades: 22 March 2013 - 02:32 AM
Reason for edit:: Added code tags

Was This Post Helpful? 0
  • +
  • -

#7 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3616
  • View blog
  • Posts: 11,263
  • Joined: 05-May 12

Re: display 1234

Posted 22 March 2013 - 05:19 AM

You need to better describe "its just not working". Are space aliens coming out of your data port? Are sparks being displayed?

Did you even take time to read post #3?

This post has been edited by Skydiver: 22 March 2013 - 05:20 AM

Was This Post Helpful? 0
  • +
  • -

#8 jimblumberg  Icon User is offline

  • member icon


Reputation: 4133
  • View blog
  • Posts: 12,865
  • Joined: 25-December 09

Re: display 1234

Posted 22 March 2013 - 06:43 AM

I also recommend you stop trying to copy someone else's broken code and write your own.

Also if you have a question start a new topic, don't hijack an old thread with a "it doesn't work" post.

Jim

This post has been edited by jimblumberg: 22 March 2013 - 06:45 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1