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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/09/12 04:59
Read: 1228 times


 
#187645 - need help - 93c46 using AT89s52 - mikroc
Responding to: Michael Karas's previous message
good day Mr. Michael karas..

thanks for the advise..

FYI, this EEPROM is o/b already and the said code is working with Keil...

but when i ports it through MikroC, it compiles but don't work...

i have matched steps with the keil...

but i don't understand why all segments brights up.. instead of giving numbers as output.

for sure, timing is the only problem.

but unfortunately, am new bee any have no oscilloscope.
here is the keil code --


 ...
#include <reg51.h>
#include <intrins.h>
//define OP code
#define OP_EWEN_H		0x00	// 00					write enable
#define OP_EWEN_L		0x60	// 11X XXXX				write enable
#define OP_EWDS_H		0x00	// 00					disable
#define OP_EWDS_L		0x00	// 00X XXXX				disable
#define OP_WRITE_H		0x40	// 01 A6-A0				write data
#define OP_READ_H		0x80	// 10 A6-A0				read data
#define OP_ERASE_H		0xc0	// 11 A6-A0				erase a word
#define OP_ERAL_H		0x00	// 00					erase all
#define OP_ERAL_L		0x40	// 10X XXXX				erase all
#define OP_WRAL_H		0x00	// 00  					write all	
#define OP_WRAL_L		0x20	// 01X XXXX		 		write all	
//define pin
sbit CS = P3^7;
sbit SK = P3^6;
sbit DI	= P3^5;
sbit DO = P3^4;
unsigned char code dis_code[] = { 0x28, 0x7E, 0xA2, 0x62, 0x74, 0x61, 0x21, 0x7A, 0x20, 0x60,0xff};//0,1,2,3,4,5,6,7,8,9,Guan, the digital code table
unsigned char       display[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
void start();
void ewen();
void ewds();
void erase();
void write(unsigned char addr, unsigned char indata);
unsigned char read(unsigned char addr);
void inop(unsigned char op_h, unsigned char op_l);
void shin(unsigned char indata);
unsigned char shout();
void delayms(unsigned int ms);
//*********************************************************
char code SST516[3] _at_ 0x003b;
main()
{
	unsigned char i,shift;
	CS = 0;							//Initialization port
	SK = 0;
	DI = 1;
	DO = 1;
	ewen();							// So as to write
	erase();							// Erasing all the contents of	
	for(i = 0 ; i < 8; i++)		//Write code to show AT93C46
	{
		write(i, dis_code[i]);
	}	
	ewds();				       	// Prohibition of write -
	for(i = 0 ; i < 8; i++)	
	{
	  display[i]=read(i);	   // Read AT93C46 content
    }
	while(1)
	{
	   shift=0x7f;
       P2=0xff ;
       for(i=0; i<8; i++)
       {  
         P0=display[i];
         P2=shift;
         shift=_cror_(shift,1);
        delayms(400);           	//Paoma Deng display
	   }	
	}
}
//*********************************************************
void write(unsigned char addr, unsigned char indata)
// Indata write data to addr
{
	inop(OP_WRITE_H, addr);			// Written instructions and addresses
		shin(indata);
		CS = 0;
	delayms(10);						// Twp
}
//*********************************************************
unsigned char read(unsigned char addr)
// Read the data addr
{
	unsigned char out_data;
	inop(OP_READ_H, addr);			//Written instructions and addresses
	out_data = shout();
	CS = 0;	
	return out_data;
}
//*********************************************************
void ewen()
{
	inop(OP_EWEN_H, OP_EWEN_L);
	CS= 0;
}
//*********************************************************
void ewds()
{
	inop(OP_EWDS_H, OP_EWDS_L);
	CS= 0;	
}
//*********************************************************
void erase()
{
	inop(OP_ERAL_H, OP_ERAL_L);
	delayms(30);
	CS = 0;
}
//*********************************************************
void inop(unsigned char op_h, unsigned char op_l)
//Op_h moved into the two high and the low seven op_l
//op_h script for the two high
//op_l script for the low seven or seven address
{	
	unsigned char i;	
	SK = 0;							// Start -
	DI = 1;
	CS = 1;
//	_nop_();
//	_nop_(); 
	SK = 1;
//	_nop_();
//	_nop_();
	SK = 0;							// The beginning of the end
	DI = (bit)(op_h & 0x80);	// High into the first script
	SK = 1;
	op_h <<= 1;
	SK = 0;		
	DI = (bit)(op_h & 0x80);	// Into the script, high
	SK = 1;
//	_nop_();
//	_nop_();	
	SK = 0;	
										// Into the rest of the script or address data
	op_l <<= 1;	
	for(i = 0; i < 7; i++)		
	{
		DI = (bit)(op_l & 0x80);// First moved into high
		SK = 1;
		op_l <<= 1;
		SK = 0;		
	}
	DI = 1;		
}
//*********************************************************
void shin(unsigned char indata)		
										//Inflow data
{
	unsigned char i;
	for(i = 0; i < 8; i++)
	{
		DI = (bit)(indata & 0x80);// First moved into high
		SK = 1;
		indata <<= 1;
		SK = 0;		
	}
	DI = 1;
}
//*********************************************************
unsigned char shout(void)			
// Data out
{
	unsigned char i, out_data;
	for(i = 0; i < 8; i++)
	{
		SK = 1;
		out_data <<= 1;
		SK = 0;
		out_data |= (unsigned char)DO;
	}
	return(out_data);
}
//*********************************************************
void delayms(unsigned int ms)	
//Delay subroutine
{						
	unsigned char i;
	while(ms--)
	{
		for(i = 0; i < 120; i++);
	}
}


 





...insert code here
 


...insert code here
 


...insert code here
 



List of 20 messages in thread
TopicAuthorDate
help me with 93c46 and at89s52---MikroC      Mandeep Singh      06/03/12 16:29      
   What You Need to Do Yourself        Michael Karas      06/03/12 17:33      
      need help - 93c46 using AT89s52 - mikroc      Mandeep Singh      06/09/12 04:59      
         MikroC is unwise choice      David Prentice      06/09/12 09:34      
   help me with 93c46 and at89s52---MikroC      Mandeep Singh      06/09/12 05:01      
      So check without scope - adjust code until testable      Per Westermark      06/09/12 06:04      
         you have now 3 times asked help with 93c46/at89s52--MikroC      Erik Malund      06/11/12 07:36      
            93c46/at89s52--MikroC      Mandeep Singh      06/11/12 10:36      
               my suggestion      Erik Malund      06/11/12 11:27      
               You have already been given suggestions      Per Westermark      06/11/12 11:55      
                  help me with 93c46 and at89s52---MikroC      Mandeep Singh      06/12/12 08:33      
                     Use a proper Compiler      David Prentice      06/12/12 08:42      
                        I wanna, I wanna, I wanna,      Erik Malund      06/12/12 09:15      
                     Time to actually prove your logic and your delays      Per Westermark      06/12/12 09:21      
                        ----thanks all for helping out      Mandeep Singh      06/12/12 10:54      
                           do you REALLY expect ....      Erik Malund      06/12/12 11:29      
                     If you can't get MikroC to work ...      Richard Erlacher      06/12/12 15:25      
                        switching to keil      Mandeep Singh      06/13/12 14:32      
                           Example code on this website      David Prentice      06/13/12 15:05      
                           why, oh why      Erik Malund      06/13/12 18:06      

Back to Subject List