This is an example application for our "Extend PIC Microcontroller‘s RAM by without using EMI" blog post. In this system PIC16F887 microcontroller is interface with four units of UM61512AK – 64K × 8 CMOS SRAMs. Monitoring signal is supplied to the MCU through “PORT A” and all the communications are performing through RS232 interface.

In my previous post most of the readers ask me about pure C language routine(s) for memory access. To fulfill that request I rewrite both memory read and write operations using C programming language. Compared with the previous Assembly language routines, only performance glitch in this implementation is 16bit address decoding part (which consume some CPU cycles than assembly language implementation)

//==============================================================================
// Function to write data to the external memory bank
// Input parameters:
//   wrt_bank: Memory band number. Valid range is between 1 to 7. 0 for no bank.
//   wrt_address: Memory address to write.
//   wrt_value: Value to write
// Return:
//   none
//==============================================================================
 
void write_to_memory(char wrt_bank, unsigned long wrt_address, char wrt_value)
{
   char port_value=2;
   set_tris_d(255);
   output_c(port_value);
   output_b(wrt_address >> 8);
   delay_us(2);
   port_value |= 1;
   output_c(port_value);
   delay_us(2);
   port_value &= 254;
   output_c(port_value);
   output_b(wrt_address & 255);
   output_d(wrt_value);
   port_value &= 253;
   output_c(port_value);
   port_value |= (wrt_bank << 2);
   output_c(port_value);
   delay_us(2);
   output_c(2);
   set_tris_d(0);
}

//==============================================================================
// Function to read data from external memory bank
// Input parameters:
//   red_bank: Memory band number. Valid range is between 1 to 7. 0 for no bank.
//   red_address: Memory address to read.
// Return:
//   Data value
//==============================================================================
 
char read_from_memory(char red_bank, unsigned long red_address)
{
   char port_value=2, ret_;
   set_tris_d(0);
   output_c(port_value);
   output_b(red_address >> 8);
   delay_us(2);
   port_value |= 1;
   output_c(port_value);
   delay_us(2);
   port_value &= 254;
   output_c(port_value);
   output_b(red_address & 255);
   port_value |= (red_bank << 2);
   output_c(port_value);
   delay_us(2);
   ret_=input_d();
   output_c(2);
   return ret_;
}

With this given firmware user can operate this system by without installing any driver software in the host side. All the data capturing and reporting operating are done by MCU itself.

This is an open hardware project. All the firmware source codes are released under the terms of GNU Lesser General Public License (LGPL) 3.0 and all the documents and other resources are released under the terms of Creative Commons Attribution-ShareAlike 3.0 Unported License.

Project Resources


Project source codes and schematic files

References


Extend PIC Microcontroller‘s RAM by without using EMI
PIC16F887 - 40 Pin, Enhanced Flash-Based 8-Bit CMOS Microcontroller with nanoWatt Technology
UM61512A - 64K x 8 - High Speed CMOS Static RAM
MAX232 - Dual EIA-232 Driver/Receiver
74HC373 - Octal D-Type Transparent Latches and Edge-Triggered Flip-Flops
74HC138 - 1-of-8 Decoder/Demultiplexer