Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/20/08 08:23
Read: times


 
#151192 - sdcc
Responding to: ???'s previous message
The following changes have been made:

  • #include <compiler.h> - adds all-'51-C-compatible definitions (thanks to Maarten Brock)
  • changed the SBIT declarations to be conformant with compiler.h
  • moved the rd_wr initialisation (where the compiler wrote the error when you tried) into the initialisation function - you cannot have statements outside functions
  • moved local variables declarations in numdsp before the first function call

Now it compiles clean in SDCC (except warnings on obsolete reg51.h, but the hint how to resolve it is written there too); and although I can't try at the moment, it should now compile on Keil, too (you need to pick compiler.h from SDCC and copy it into the includes directory of Keil).

This does not mean that it is functionally correct nor that it is a nice programming style... ;-)

Have fun!

Jan Waclawek

----------------------

#include <compiler.h>
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int

SBIT(ena, 0x80, 1);
SBIT(rs, 0x80, 2);
SBIT(rd_wr, 0x80, 0);


void lcddatwr(uchar dbyte){
	rs=1;
	ena=1;
	P1=dbyte;
	ena=0;
	rd_wr=1;
}

void lcdcmdwr(uchar dbyte){
	rs=1;
	ena=1;
	P1=dbyte;
	ena=0;
}

void display (uchar startloc, uchar *s){
	lcdcmdwr(0x80 | startloc);
	while(*s) {lcddatwr(*s++);
	}
}
//This funktion stil try to understand its funktionality 
void numdsp(uchar startloc, uint number, bit dpt){
	uint m=1000;
	bit ldgzero=0;	//hear shows also wrong
	lcdcmdwr(0x80 | startloc);
	do{
		if((((number/m)>0) || (m==1)) || ((m==100) && (dpt==1))) ldgzero=1;
		if (ldgzero == 1) lcddatwr(number/m+'0');
		else lcddatwr(' ');
		number %=m;
		if ((dpt==1) && (m==100)){
			lcddatwr('.');
	  }
	 }while((m/=10)>0);
}

	void initialize(void){
rd_wr=1; //i want this bit always 1 but point me wrong message
		lcdcmdwr(0x30);	
		
	}

	void main(void){
		uint x=0;
		initialize();
		display(0, "test");
		for(;;){
		numdsp(69,x++,0);
		}
}


List of 8 messages in thread
TopicAuthorDate
Display, C code problem            01/01/70 00:00      
   RE: wrong messages?            01/01/70 00:00      
      that sounds strange            01/01/70 00:00      
         stranger            01/01/70 00:00      
            I 'know' it would not, however            01/01/70 00:00      
   sdcc            01/01/70 00:00      
   the wrong messages            01/01/70 00:00      
      error messages            01/01/70 00:00      

Back to Subject List