Site icon Ercan Koçlar

LH52256 SRAM MicroC Library

LH52256-SRAM-kapak

LH52256-SRAM-kapak

This post is also available in: Türkçe


 


What is SRAM?

LH52256 Static RAM

Why RAM is Used With PIC?

General Information about LH52256  and RAMs

LH52256 MicroC Library and General Principle of its Circuit

74HC164 shift register integration
74HC164 Running Principle

 

LH52256 Pin Functions

LH52256 Pins
Pin Name Function
A0 – A14 Address Entry
CE Selects RAM
WE Writing Function
OE Reading Function
I/O1 – I/O8 Data Input and Output
Vcc Feeding +5V
GND Grounding

 

74HC164 Pin Function

74HC164 Pin Function
Symbol Pin Description
DSA 1 Data Input
DSB 2 Data Input
Q0 – Q7 3,4,5,6,10,11,12,13 Output
GND 7 Grounding
CP 8 Clock Pulse
MR 9 Master Reset
Vcc 14 Feeding +5v

LH52256 Running Protocols

 

General Worksheet

CE WE OE Mode I/O1-I/O8 Feeding
H x x Idle High Level 0.6 mA
L H L Reading Data Output 25 mA
L H H Output  Cancellation High Level 25 mA
L L x Writing Data Input 25 mA

 

LH52256 Data Reading Function

LH52256 Data Reading Function

 

LH52256 Data Writing Process

LH52256 Data Writing Process

 

LH52256 SRAM Circuit

 

LH52256 Circuit Scheme

LH52256 SRAM Circuit Scheme- Click on Image to Enlarge

Necessary Materials

  1. 2 pcs 74HC164 shift registry integration
  2. 2 pcs 14 pin integration socket (for 74HC164)
  3. 4 pcs LH52256 SRAM integration (or 1 piece preferably)
  4. 4 pcs narrow type 28 pins integration socket
  5. 6 pcs 0.1uf condenser
  6. Pertinax
  7. Percision female and male sockets ( may differ according to circuit)

Making Circuit

LH52256 SRAM Circuit General Outlook

 

LH52256 SRAM Circuit General Outlook 2

 

LH52256 SRAM Sockets

 

LH52256 SRAM Sockets 2

 

LH52256 SRAM MicroC Library

Functions

Shift Register Functions

 

– LH52256_RESET_RUTINI Function

Function: void LH52256_RESET_RUTINI()

Purpose : Deleting all previously written data on the 74HC164 makes the outputs “0“. Deletes address information

Parameters : N/A

How to Use :

LH52256_RESET_RUTINI();

Feedback :  being in void type does not provide feedback

 

– LH52256_SHIFT_REGISTER_VERI_GONDERME_RUTINI Function

Function : void LH5225_SHIFT_REGISTER_VERI_GONDERME_RUTINI(unsigned char VERI)

Purpose : Provides data to be uploaded to 74HC164

Parameters :

How to Use :

LH5225_SHIFT_REGISTER_VERI_GONDERME_RUTINI(1);//loads into shift register lojik 1 data, therefore next port lojik is 1

Feedback : Being in void type does not provide feedback

 

– LH52256_ADRES_SECMEFunction

Function: unsigned char  LH52256_ADRES_SECME (unsigned int RAM_ADRESI)

Purpose: The LH52256 allows address selection in SRAM.

Parameters: 

How to Use:

LH52256_ADRES_SECME(125);// SRAM in 125. address is selected

Feedback:

 

General SRAM Functions

 

– LH52256_ANALIZ Functions

Functions: unsigned char LH52256_ANALIZ()

Purpose: Analyzes installed RAM and makes initial pin-port adjustments

Parameters : N/A

How to Use:

LH52256_ANALIZ();//RAMs in the system are analyzed

Feedback:

 

– LH52256_RAM_SECME Function

Function : void LH52256_RAM_SECME(unsigned char RAM_NUMARASI)

Purpose:

Parameters: 

How to Use:

LH52256_RAM_SECME(4);//The RAM which is inserted into 4th socket is activated.

Feedback : Since it is void type, it does not provide feedback.

 

– LH52256_DERINLEMESINE_TEST Function

Function: unsigned char LH52256_DERINLEMESINE_TEST(unsigned char RAM_NUMARASI)

Purpose: Controls all addresses of the selected RAM individually

Parameters:

How to Use:

LH52256_DERINLEMESINE_TEST(2);//The RAM with socket number 2 performs an in-depth review

Feedback:

 

SRAM Data Writing Functions

 

– LH52256_RAM_VERI_YAZMA_RUTINI_SABIT  Function

Function : void LH52256_RAM_VERI_YAZMA_RUTINI_SABIT(unsigned char VERI)

Purpose: Writes 8 bit data

Parameters:

How to Use:

LH52256_RAM_VERI_YAZMA_RUTINI_SABIT(125);

Feedback: Since it is a void type, there is no feedback.

 

– LH52256_RAM_VERI_YAZMA_RUTINI_ARTTIRIMLI Function

Function: void LH52256_RAM_VERI_YAZMA_RUTINI_ARTTIRIMLI(unsigned char VERI,unsigned char *HATA)

Purpose: Writes 8 bits of data and automatically increases the address one time

Parameters:

How to Use:

unsigned char abc;

LH52256_RAM_VERI_YAZMA_RUTINI_ARTTIRIMLI(125,abc);//While sending 125 data, the code to be received from pointer can be read from abc variable

Feedback: Since it is a void type, there is no feedback

 

– LH52256_RAM_VERI_YAZMA_RUTINI_AZALTIMLI Function

Function : void LH52256_RAM_VERI_YAZMA_RUTINI_AZALTIMLI(unsigned char VERI,unsigned char *HATA)

Purpose: Writes 8 bits of data and automatically reduces the address once.

Parameters:

unsigned char abc;

LH52256_RAM_VERI_YAZMA_RUTINI_AZALTIMLI(125,abc);//When sending 125 data, the code that comes from the pointer can be read from the variable abc

Feedback: Since it is a void type, there is no feedback

 

SRAM Data Reading Functions

 

– LH52256_RAM_VERI_OKUMA_RUTINI_SABIT Fonksiyonu

Function: unsigned char LH52256_RAM_VERI_OKUMA_RUTINI_SABIT ()

Purpose:  Reads 8 bits of data from RAM.

Parameters : N/A

How to Use:

unsigned char okunan_veri;

okunan_veri = LH52256_RAM_VERI_OKUMA_RUTINI_SABIT();

Feedback: Brings the value it read.

 

– LH52256_RAM_VERI_OKUMA_RUTINI_ARTTIRIMLI Function

Function: unsigned char LH52256_RAM_VERI_OKUMA_RUTINI_ARTTIRIMLI(unsigned char *HATA)

Purpose: Writes 8 bits of data and automatically increases the address one time

Parameters:

How to Use:

unsigned char okunan_veri,abc;

okunan_veri = LH52256_RAM_VERI_OKUMA_RUTINI_ARTTIRIMLI(abc);

Feedback: Brings the value it read.

 

– LH52256_RAM_VERI_OKUMA_RUTINI_AZALTIMLI Function

Function: unsigned char LH52256_RAM_VERI_OKUMA_RUTINI_AZALTIMLI(unsigned char *HATA)

Purpose: Writes 8 bits of data and automatically reduces the address once.

Parameters:

How to Use:

unsigned char okunan_veri,abc;

okunan_veri = LH52256_RAM_VERI_OKUMA_RUTINI_AZALTIMLI(abc);

Feedback: Brings the value it read.

 

Application of Functions

Pin Identification

 sbit LH52256_CP   at RE0_bit;        //74164 Clock- clk
 sbit LH52256_DSA  at RE2_bit;        //74164 Shift register data is set here 1 or 0
 sbit LH52256_MR   at RE1_bit;        //74164 RESET
 char LH52256_DATA at portb;          //ram data I/O  entry
 sbit LH52256_CE1  at RA0_bit;        //ram1 chip enable
 sbit LH52256_CE2  at RA1_bit;        //ram2 chip enable
 sbit LH52256_CE3  at RA2_bit;        //ram3 chip enable
 sbit LH52256_CE4  at RA3_bit;        //ram4 chip enable
 sbit LH52256_WE   at RA5_bit;       //ram write enable
 sbit LH52256_OE   at RA4_bit;
 
 sbit LH52256_CP_Direction   at TRISE0_bit;
 sbit LH52256_DSA_Direction  at TRISE2_bit;
 sbit LH52256_MR_Direction   at TRISE1_bit;
 char LH52256_DATA_Direction at TRISB;
 sbit LH52256_CE1_Direction  at TRISA0_bit;
 sbit LH52256_CE2_Direction  at TRISA1_bit;
 sbit LH52256_CE3_Direction  at TRISA2_bit;
 sbit LH52256_CE4_Direction  at TRISA3_bit;
 sbit LH52256_WE_Direction   at TRISA5_bit;
 sbit LH52256_OE_Direction   at TRISA4_bit;

 

SRAM Analysis

void  main()
{
    unsigned char ram_sayisi=0;
    char txt[12];//required for circuit
    ADCON1=0b00001111;//all analog entries are made digital
    CMCON=7;//conperators are closed
  
    SAP1024_INIT(240,128,6);//GLCD screen libraries are set  
  
    ram_sayisi=LH52256_ANALIZ();//RAMs in system are analyzed
  
   //Results are set as srt and screed in GLCD  
   WORDtostr(ram_sayisi,txt);
   SAP1024_YAZI_YAZMA(10,10,txt);

}

 

SRAM Reading Function

void  main()
{
    unsigned char veri=0; 
    char txt[12];//required for circuit 
    ADCON1=0b00001111;//all analog entries are made digital 
    CMCON=7;//comperators are closed

    SAP1024_INIT(240,128,6);//GLCD screen libraries are set 
  
    LH52256_ANALIZ();

    LH52256_ADRES_SECME(32766);//32766. SRAM address is selected
    
    LH52256_RAM_SECME(1);//number 1 SRAM is selected
   
    veri= LH52256_RAM_VERI_OKUMA_RUTINI_SABIT();//the read values are transferred into "data" variable
  
  

   //Results are set as srt and screed in GLCD 
    WORDtostr(veri,txt);
    SAP1024_YAZI_YAZMA(10,10,txt);

}
void  main()
{
    unsigned char veri=0,hata_kodu;
    unsigned int i=0; 
    char txt[12];//required for circuit 
    ADCON1=0b00001111;//all analog entries are made digital  
    CMCON=7;//comperators are closed

    SAP1024_INIT(240,128,6);//GLCD screen libraries are set
  
    LH52256_ANALIZ();

    LH52256_ADRES_SECME(0);//0th SRAM address is selected
    
    LH52256_RAM_SECME(1);//1 SRAM address is selected
   
    for(i=0;i<32768;i++)
       {
         veri= LH52256_RAM_VERI_OKUMA_RUTINI_ARTTIRIMLI(hata_kodu);//the read data is transferred to the "data" variable and the address is incremented
       
          if(hata_kodu==0)//if there is address error
            {
               return;//end the process 

         //Results are converted into str and displayed in GLCD
         WORDtostr(veri,txt);
         SAP1024_YAZI_YAZMA(10,10,txt);
       }

}

 

SRAM Writing Function

void  main()
{
    char txt[12];//required for circuit  
    ADCON1=0b00001111;//all analog entries are made digital 
    CMCON=7;//comperators are closed

    SAP1024_INIT(240,128,6);//GLCD screen libraries are set
  
    LH52256_ANALIZ();

    LH52256_ADRES_SECME(100);//100th SRAM address is selected
    
    LH52256_RAM_SECME(3);//3rd SRAM address is selected
   
    LH52256_RAM_VERI_YAZMA_RUTINI_SABIT(235);//235 is written to the selected address 
  
  

   //Results are set as srt and screed in GLCD 
    WORDtostr(veri,txt);
    SAP1024_YAZI_YAZMA(10,10,txt);

}
void  main()
{
    unsigned char hata_kodu;
    unsigned int i=0; 
    char txt[12];//required for circuit  
    ADCON1=0b00001111;//all analog entries are made digital 
    CMCON=7;//comperators are closed

    SAP1024_INIT(240,128,6);//GLCD screen libraries are set
  
    LH52256_ANALIZ();

    LH52256_ADRES_SECME(0);//0th SRAM address is selected
    
    LH52256_RAM_SECME(3);//3rd SRAM address is selected
   
    for(i=0;i<1200;i++)
       {
         LH52256_RAM_VERI_YAZMA_RUTINI_ARTTIRIMLI(120,hata_kodu);//120 is written into all addresses from 0 to 1200
       
          if(hata_kodu==0)//if you get an address error
            {
               return;//end the process
            } 

         //Results are set as srt and screened in GLCD
         WORDtostr(veri,txt);
         SAP1024_YAZI_YAZMA(10,10,txt);
       }

}

 

SRAM Deep Analysis

void  main()
{
    char txt[12];//required for circuit 
    unsigned char ram_sayisi=0; 
    ADCON1=0b00001111;//all analog entries are made digital 
    CMCON=7;//comperators are closed

    SAP1024_INIT(240,128,6);//GLCD screen libraries are set
  
    LH52256_ANALIZ();
  
    ram_sayisi=LH52256_DERINLEMESINE_TEST(1);//detailed test is applied to the 1st RAM

   //Results are set as srt and screened in GLCD 
    WORDtostr(ram_sayisi,txt);
    SAP1024_YAZI_YAZMA(10,10,txt);

}

Experiment Video


CONCLUSION


Library Files


References


 

Exit mobile version