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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/26/12 21:56
Read: 737 times


 
#185695 - interfacing with 93c66
Responding to: ???'s previous message
friends this coad is not store data in external memory.i get coad of 93c46 from 8052 library and try to edit for 93c66 but i do more effort but this coad is not storing data in external memory.

so plz check it .

/*****************************************/
/*			 0000 to 9999 Display		 */
/*			 with 4094					 */
/*                                       */
/*****************************************/
#include <REGX51.H>
 
unsigned char buffer[5];
unsigned int num1,num2,num3,num4,num5,test=0;
unsigned int num=0;
void Initialize(void);					// Function to Initiallize Variables									
void ROM(void);							// Function to deal with EEPROM(93C46B)									
void ERASE_WRITE (void);				// Function for write cycle of 93C46B							
int ROM_WRD;							// ROM_WRD acts as a IO buffer for the EEPROM							
char ROM_OPAD;							// ROM_OPAD keeps current OPCODE+ADDRESS for the EEPROM																			

sbit CLK    = P2^1;
sbit DIN    = P2^0;
sbit strobe = P2^2;

sbit ROM_CS	= P1^4;						// P1.4 EEPROM CS pin of 93C46B is connected here						
sbit ROM_DO = P1^7;						// p1.5	EEPROM DI pin of 93C46B is connected here						
sbit ROM_DI = P1^6;						// P1.6 EEPROM DO pin of 93C46B is connected here 						
sbit ROM_CK = P1^5;						// P1.7 EEPROM CK pin of 93C46B is connected here											
											
sbit up    = P1^0;
sbit down  = P1^1;
sbit reset = P1^2;
sbit set   = P1^3;

char code segment[11]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x39};


void delay(int num)   // timer 							
{ 
	int i;
	for(i=0;i<num;i++)
	{	
		TH0=0xfc;
		TL0=0x67;
	}	 
}

void Initialize(void)																							
{																												
	ROM_DO	=1;							//  Get Ready to receive data on this pin								
	ROM_OPAD=0x80;						// 	Make it a read command so nothing is erased							
	ROM();								/*  Call to ROM Routine to cancel out false start bit given				
											because when 8051 starts all its pins are at logic 1 				
											but ROM_CS = ROM_DI = ROM_CK = 1 means start bit for ROM			
											We Shall keep ROM_CK = 0 in future and this is done at the 			
											end of ROM() function*/ //		
}

void ROM(void)							//																		
{										//																		
		char i;							// Variable to count in loops											
		unsigned char ROM_OP=ROM_OPAD;	// Copy ROM OPCODE from OPCODE+ADDRESS byte								
		ROM_OP&=0xC0;					// Decode ROM OPCODE (i.e. Remove Address)								
		if (!ROM_OP)					// OPCODE = 00?															
		{								//																		
			ROM_OP=ROM_OPAD & 0x30;	// Mask so only first two bits of the Address field of ROM_OPAD Remain	
			if (ROM_OP == 0x10) 		// A WRAL command?														
				ROM_OP=0x100;			// Convert it to a write Command to send 16 bits to EEPROM after OPAD	
		}								//																		
		//-------------------Start Bit---------------------------//												
 			ROM_CS=1;					// Select the ROM Chip													
			ROM_DI=1;					// Start bit ready														
			ROM_CK=1;					// Start bit given by Positive edge of clock							
																												
		//----------------------OPCODE+ADDRESS-------------------//												
			for(i=0;i<8;i++)			// Give OPAD (Opcode + Address) Byte to EEPROM							
			{							//																		
				ROM_CK=0;				// Get ROM clock ready													
				ROM_OPAD<<=1;			// Left-shift ROM OPCODE+ADDRESS by one bit. Carry = MSB				
				ROM_DI=CY;				// Put the carry bit onto ROM Data In 									
				ROM_CK=1;				// Give this bit to ROM by Positive edge of clock						
			}							//																		
																												
		//------------------------Write--------------------------//												
			if(ROM_OP==0x100)			// ROM OPCODE is for WRITE or WRAL(Write ALL) instruction?				
			{							//																		
				for(i=0;i<16;i++)		// Give the 16 bit Data to the ROM										
				{						//																		
					ROM_CK = 0;			// Get ROM clock ready													
					ROM_WRD <<= 1;		// Left-shift ROM_WRD by one bit. Carry = MSB							
					ROM_DI = CY;		// Put the carry bit into ROM Data In									
					ROM_CK = 1;			// Give this bit to ROM by Positive edge of clock						
				}						//																		
			}							//																		
		//------------------------READ--------------------------//												
			else if(ROM_OP==0x80 )		// ROM OPCODE for Read Instruction?										
			{							//																		
				ROM_WRD=0;				// Initiallize ROM_WRD to store read DATA								
				for(i=0;i<16;i++)		// Read the 16 bit Data from the ROM									
				{						//																		
					ROM_CK = 0;			// Get ROM clock ready													
					ROM_CK = 1;			// Give Positive edge of clock for ROM to put MSB at ADDRESS on DO		
					ROM_WRD <<=1;		// Left_shift the ROM_WRD to make room for new bit to ADD				
					if (ROM_DO)			// A '1'?																
						ROM_WRD++;		// Add '1'to ROM_WRD													
				}						//																		
			}							//																		
		ROM_CS=0;						// Unselect the ROM chip												
		ROM_DI=0;						// Reset the ROM DI														
		ROM_CK=0;						// Get Ready for next Start Bit											
}										//																		
																												
void ERASE_WRITE (void)					//																		
{										//																			
	char TEMP;							//  Temporay storage of a byte											
	TEMP=ROM_OPAD;						//  Save a copy of user's OPCODE + Address								
	ROM_OPAD=0x30;						// 	EWEN COMMAND for ROM (00110000)									
	ROM();								// 	CALL to ROM Function to send command								
	ROM_OPAD=TEMP;						// 	Restore the copy of user's OPCODE + Address							
	ROM();								// 	Call to ROM Function for writing the data to respective Location	
	ROM_CS=1;							//  Select ROM Chip to read status										
	while(!ROM_DO);						//  Wait for ROM chip to become ready									
	ROM_OPAD=0x00;						// 	EWDS Command (00000000)											
	ROM();								// 	Call to ROM Function to Send command								
}													

void write_led()
{
     char i,j;

	 for(j=0; j<5; j++)
	 {
	 for(i=0;i<8; i++)
    	 {
           if(buffer[j]&0x80) DIN = 1; 
           else DIN=0; 
           CLK= 1; 
           buffer[j] <<=1; 
           CLK = 0;
	     }
	 }
	strobe = 1;
    ;
    strobe = 0;
}	    

void move_Buffer()
{
    buffer[0] = segment[num1%10];
    buffer[1] = segment[num2%10];
    buffer[2] = segment[num3%10];
    buffer[3] = segment[num4%10];
    buffer[4] = segment[num5%10];
}

void updatedisplay()
{
       move_Buffer();
       write_led();
}

void counter()
   {
  if(up==0&&down==1)                                 //check if up pin is pressed
     {
   test++;
        num=test;
	    num1=num%10;
      num=num/10;
        num2=num%10;
      num=num/10;
        num3=num%10;
      num=num/10;
        num4=num%10;
      num5=num/10;
      if(test==99999)
     test=0;
    }
    if(up==1&&down==0)                         //check if down pin is pressed
    {
   test--;
        num=test;
		num1=num%10;
      num=num/10;
        num2=num%10;
      num=num/10;
        num3=num%10;
      num=num/10;
        num4=num%10;
      num5=num/10;
     if(test==0)
     test=99999;
  }
}

void re()                                             // reset display
{
  if (reset==0)
  buffer[4]=buffer[3]=buffer[2]=buffer[1]=buffer[0]=0;
 }

void timer_isr(void) interrupt 1 using 1
{
	counter();
	re();
	delay(5000);
    updatedisplay();
}

void main()
{
  Initialize();
  TMOD = 0x01;
  EA   = 1;
  ET0  = 1;
  TR0  = 1;
  up   = 1;
  down = 1;
  reset= 1;
  set  = 1;
     while(1)
	 {
	   ERASE_WRITE();
	   ROM();
	   } 
}



List of 49 messages in thread
TopicAuthorDate
interfacing with 93c66      Anil Kumar      01/14/12 01:04      
   Interfacing AT93CXXX Serial EEPROMs with AT89LP MCUs      Jan Waclawek      01/14/12 04:20      
      Direct Links      Michael Karas      01/14/12 11:04      
   interfacing ith93c66      Anil Kumar      01/16/12 03:09      
      Better Learn Both      Michael Karas      01/16/12 18:01      
      How about the 8051 code library?      Neil Kurzman      01/16/12 23:30      
         interfacing with 93c66      Anil Kumar      01/18/12 22:51      
            An exercise for the reader      David Prentice      01/19/12 01:20      
               interfacing with 93c66      Anil Kumar      01/19/12 22:59      
      Then you need to learn...      Robert Revens      01/19/12 05:34      
         I disgaree        David Prentice      01/19/12 06:25      
            cheap fatty sausage      Erik Malund      01/19/12 07:04      
               Understanding the mapping important      Per Westermark      01/19/12 07:43      
                  out of context      Erik Malund      01/19/12 09:13      
                  So exactly what was the disagreement???      Per Westermark      01/20/12 02:52      
                     I agree with you      David Prentice      01/20/12 03:55      
                        Don't simplify to believe it's about fastest speed      Per Westermark      01/20/12 05:27      
                        again      Erik Malund      01/20/12 07:48      
                     true      Erik Malund      01/20/12 07:42      
               Are you serious?      David Prentice      01/19/12 08:15      
                  also out of context      Erik Malund      01/19/12 09:16      
               Missing the point!      Andy Neil      01/19/12 12:19      
                  the full monte      Erik Malund      01/19/12 12:37      
   interfacing with 93c66      Anil Kumar      01/26/12 21:56      
      And your work      Per Westermark      01/27/12 02:46      
      plz check it      Andy Neil      01/27/12 06:58      
      ,sometimes you have to be VERY specific      Erik Malund      01/27/12 07:31      
      wrong strategy and many errors      Stefan KAnev      01/30/12 04:12      
   interfacing with 93c66      Anil Kumar      01/28/12 03:16      
      why do you resist using external ram?      Erik Malund      01/28/12 08:58      
         interfacing with 93c66      Anil Kumar      01/29/12 02:21      
            Payed support not good enough?        Per Westermark      01/29/12 03:18      
               interfacing with 93c66      Anil Kumar      01/29/12 22:29      
                  Any Specific Reason for using...      Maunik Choksi      01/29/12 23:09      
                     interfacing with 93c66      Anil Kumar      01/29/12 23:33      
                        please explain      Andy Neil      01/30/12 14:39      
                        It is advisable to use alternate available....      Maunik Choksi      01/30/12 22:37      
                           interfacing with 93c66      Anil Kumar      01/31/12 22:06      
                              Can you elaborate it ?      Maunik Choksi      01/31/12 22:44      
                                 interfacing with 93c66      Anil Kumar      01/31/12 22:51      
                                    You give me your email-id      Maunik Choksi      01/31/12 22:53      
                                       email id      Anil Kumar      01/31/12 22:57      
                                          Ok      Maunik Choksi      01/31/12 22:58      
                  Wrong - you are just not responding to on-topic questions      Per Westermark      01/30/12 03:00      
                  you've got plenty of suggestions      Erik Malund      01/30/12 06:53      
                     Off-topic but Siemens/seconds...      Per Westermark      01/30/12 08:04      
                     funny result      Erik Malund      02/02/12 09:20      
                        Output      Per Westermark      02/02/12 15:14      
   still waiting      Erik Malund      02/01/12 06:49      

Back to Subject List