Showing posts with label MikroC EEPROM. Show all posts
Showing posts with label MikroC EEPROM. Show all posts

AVR EEPROM Tutorial


 EEPROM

EEPROM (Electrically Erasable Programmable Read-Only Memory) is a type of non-volatile memory which can be programmed, erased, and re-programmed electrically while it is on the circuit board. A majority of AVR microcontrollers come with some built-in EEPROM which is a great place to store data that should not be lost when the system is powered down. This tutorial explains the MikroC EEPROM library with example


MikroC EEPROM Library

EEPROM data memory is available with a number of AVR family. The mikroC PRO for AVR includes a library for comfortable work with MCU's internal EEPROM.
  Important : EEPROM Library functions implementation is MCU dependent, consult the appropriate MCU datasheet for details about available EEPROM size and address range.
Library Routines
EEPROM_Read
Prototype
unsigned short EEPROM_Read(unsigned int address);
Returns
Byte from the specified address.
Description
Reads data from specified address.
Parameters :
  • address: address of the EEPROM memory location to be read.
Requires
Nothing.
Example
unsigned int address = 2;
unsigned short temp;
...
temp = EEPROM_Read(address);
EEPROM_Write
Prototype
void EEPROM_Write(unsigned address, unsigned short dData);
Returns
Nothing.
Description
Writes wrdata to specified address.
Parameters :
  • address: address of the EEPROM memory location to be written.
  • wrdata: data to be written.
  Note : Specified memory location will be erased before writing starts.

Example
unsigned address = 0x732;
unsigned short dData = 0x55;
...
EEPROM_Write(address, dData);
Example
This example demonstrates using the EEPROM Library with ATMEGA16 MCU.
First, some data is written to EEPROM in byte and block mode; then the data is read from the same locations and displayed on PORTA, PORTB and PORTC.
char ii;                                   // loop variable

void main(){
   DDRA = 0xFF;                            // Set signal port as output
   DDRB = 0xFF;                            // Set signal port as output
   DDRC = 0xFF;                            // Set signal port as output
  
   PORTA = 0x00;                           // Clear signal ports
   PORTB = 0x00;
   PORTC = 0x00;
   Delay_ms(2000);

   EEPROM_Write(0x02,0xAA);                // Write some data at address 2
   EEPROM_Write(0x150,0x55);               // Write some data at address 0x150

   PORTA = EEPROM_Read(0x02);              // Read data from address 2 and display it on PORTA
   PORTB = EEPROM_Read(0x150);             // Read data from address 0x150 and display it on PORTB

   Delay_ms(1000);

   for(ii = 0; ii < 32; ii++)              // EEPROM write loop
     EEPROM_Write(0x100+ii, ii);           // Write data to address 0x100+ii

   for(ii = 0; ii < 32; ii++) {            // EEPROM read loop
     PORTC = EEPROM_Read(0x100+ii);        // Read data from address 0x100+ii
     Delay_ms(100);                        //   and display it on PORTC
   }
  
}



Circuit


PIC Microcontroller Based Electronic Lock

 Circuit Diagram

Security is a prime concern in our day-today life. Everyone wants to be as much secure as possible. An access control for doors forms a vital link in a security chain. The microcontroller based digital lock for Doors is an access control system that allows only authorized persons to access a restricted area.
An electronic lock or digital lock is a device which has an electronic control assembly attached to it. They are provided with an access control system. This system allows the user to unlock the device with a password. The password is entered by making use of a keypad. The user can also set his password to ensure better protection. The major components include a Keypad, LCD and the controller PIC16F877A. This article describes the making of an electronic code lock using the 16F877A microcontroller.

The system is fully controlled by the 8 bit microcontroller 16F877A which has a 8Kbytes of ROM for the program memory. The password is stored in the EPROM so that we can change it at any time. The system has a Keypad by which the password can be entered through it. When the entered password equals with the password stored in the memory then the relay gets on and so that the door is opened.

The code is built in a modular style to allow a user to find ways to modify  project. In start the D Lock programs loads with a default code of "2345" format is *2345# which can be enter to unlock the door, the code cam be change by entering the master code in the format *23455#new 4 digit code.  In this program i only display the result on LCD and lock will be  placed at   PORTA bit 0 where i put led for simulation. 



A 4x3 matrix keypad and a 16x2 LCD have been used here. Keypad and LCD are very commonly used input & output devices, respectively. The password is stored in the system EEPROM.
While unlocking, if the entered password from keypad matches with the stored password, then the lock opens and a message is displayed on LCD. Also an output pin is made high to be used for further purpose..

As the program starts, wait for 5sec and press * string ‘Enter Password’ is displayed on LCD. The keypad is scanned for pressed digits one by one. Every time, row and column of the key pressed is detected and is displayed on LCD. After the four digits are entered, the user should press # to Confirm Password and again the input is taken through LCD. If the passwords do not match, a message is displayed to indicate ‘Access Denied’ otherwise the ‘Access Granted’ message.

The default password is 2345 and master key to change password is 23455., entry begins with * and stops with #.

Update 28-8-2013

 1. Here two circuit are provided, the smaller one works only for 

simulation and the larger one works only    in real world( Problem

with Pull Down resistors)

2. Due to frequent Requests I have Uploaded the HEX(8Mhz Crystal) file of these project in Our Facebook Group-Click Here

Code 

 

  Discussion Group




Facebook Page                                                                                                                  Contents Page

 


Check Our New Blog: Embedded Projects-Tutorials-Arduino-Android-Raspberry PI- Gadgets News - Embedded Hackes - New Embedded Products Intro etc 

 (click the Image Below to Visit the Blog)

www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCoQFjAA&url=http%3A%2F%2Farrogancegizmo.blogspot.com%2F&ei=SMaRUsGzCYj_rAfA-4GoDw&usg=AFQjCNEw6Pm6VepdEnZlm1evPy5f0N2NdA&sig2=sG5PkXDQilaUfIan6u2Wzw&bvm=bv.56988011,d.bmk
 
 
Copyright Electronics Projects And Details All Rights Reserved
ProSense theme created by Dosh Dosh and The Wrong Advices.
Blogerized by Alat Recording Studio Rekaman.