Line 1: Line 1:
 
[[Category:8051 tutorials]]
 
[[Category:8051 tutorials]]
 +
In this tutorial, we will see how to use XploreFlash for flashing the hex files to AT89s52.<br>
 +
First, we will see how to install the XploreFlash software along with UsbAsp drivers and then continue with flashing the controller.
  
The keypad matrix or hex keypad comprising of 16 keys arranged as 4x4 matrix is one of the common interfaces done to a micrcontroller.  
+
=Installing UsbAsp Drivers=
 +
Download the UsbAsp drivers from this link and follow the below steps.<br>
 +
In case your are using <b>Windows7/Vista/Xp</b>, skip the first 7 steps and directly jump to step8.<br>
  
These are similar to a telephone keypad that we normally come across. In this tutorial we will see about interfacing this keypad to 8051. We will write the code to scan the keys and display the pressed key on the LCD.
+
Windows 8 and above do not allow the installation of drivers that are not digitally signed. This needs to be disabled by following the below steps.<br>
  
=Video Tutorial=
+
<b>STEP 1:</b>Go to Advanced Start Options by searching the same in Windows Start Menu.
==Keypad Scan Algorithm-Part 1==
+
[[FILE:UsbAsp Setup Steps.png ]]  <br>
{{#ev:youtube|6u_3dr5utSU|680|auto}}
+
==Keypad, Code and Demo- Part 2==
+
{{#ev:youtube|H5eg11802A0|680|auto}}
+
  
==Code and Demo==
+
<b>STEP 2:</b> Click on Restart Now in Advanced Start Up options.
=Basics=
+
[[FILE:UsbAsp Setup Steps 1.png]]  <br>
  
 +
<b>STEP 3:</b> Now choose the Troubleshoot option.
 +
[[FILE:UsbAsp Setup Steps 2.jpg]]  <br>
  
 +
<b>STEP 4:</b> Click on Advanced Options.
 +
[[FILE:UsbAsp Setup Steps 3.jpg]]  <br>
  
=Working=
+
<b>STEP 5:</b> Click on StartUp Settings.
{{Box|type=l_green_light|text=<br />
+
[[FILE:UsbAsp Setup Steps 4.jpg]]  <br>
For us human beings it takes a few seconds to press a key, but the controller can read the port pin and eventually the keypressed in milliseconds.  
+
Hence it is possible to scan a four or more rows and columns while the key is being pressed! In fact, when we will test the code we will realize that a single key press is detected multiple times.
+
*KeyBounce: Multiple keypress is also resulted out of mechanical construction of the keys. When we press and release a key, it not just presses once but debounces several times.
+
  
There are various ways to eliminate debounce, however we will use time delay to neglect the effect of keybounce.   
+
<b>STEP 6:</b> Now Click on Restart and wait till the PC restarts.
 +
[[FILE:UsbAsp Setup Steps 5.jpg]] <br>
  
}}
+
<b>STEP 7:</b> Once the PC restarts, Press 7/F7 to disable <b>Driver Signature Enforcement</b>.  
='''Schematic:'''=
+
[[FILE:UsbAsp Setup Steps 6.jpg]] <br>
Figure below shows the schematic of a keypad interfaced with 8051 micrcontroller. We have tested it with P89V51RD2, you may wish to try in on any other 8051 family MCUs.<br />
+
{{#widget:Iframe
+
|url=http://xplorelabz.com/wiki/images/6/65/SCH_Image.PNG
+
|width=700
+
|height=400
+
|border=5
+
}}
+
[http://xplorelabz.com/wiki/images/c/cc/Keypad_8051.pdf Download Schematic pdf]
+
  
='''Code'''=
+
<b>STEP 8:</b> Now Connect the Usbasp programmer to the system and it will be listed under other devices in device manager.
{{Box|type=l_green_light|text=<br />
+
[[FILE:UsbAsp Setup Steps 7.PNG]]  <br>
As with all our other projects, we divide the files according to interfaces, hence we have '''lcd_4_bit.c''' as file for displaying messages on LCD, '''keypad.c''' has functions to scan and return a key pressed.
+
The main code demonstrates how to read a key and display on the LCD.  
+
}}
+
<syntaxhighlight>
+
/* Reg51.h contains the defnition of all ports and SFRs */
+
#include <reg51.h>  
+
  
#include "lcd.h" //User defined LCD library which conatins the lcd routines
+
<b>STEP 9:</b> Right Click and choose <b>Update Driver Software</b>
#include "keypad.h" //User defined library which conatins the keypad routines
+
[[FILE:UsbAsp Setup Steps 8.png]]  <br>
  
 +
<b>STEP 10:</b>Now browse and select the folder where the drivers are stored.
 +
[[FILE:UsbAsp Setup Steps 9.PNG]]  <br>
  
/* start the main program */
+
<b>STEP 11:</b> After selecting the driver folder, click on Next to install the drivers.
void main()
+
[[FILE:UsbAsp Setup Steps 10.PNG]]  <br>
{
+
unsigned char key;
+
  /* Initilize the lcd before displaying any thing on the lcd */
+
    LCD_Init();
+
  
  /* Initilize the keypad port pins */
+
<b>STEP 12: Click on <b>Install This Software Anyway</b>
  KEYPAD_Init();
+
[[FILE:UsbAsp Setup Steps 11.PNG]]  <br>
  
  LCD_DisplayString("Key Press: ");
+
<b>STEP 13:</b> Once the installion is successful, below message will be displayed.
 +
[[FILE:UsbAsp Setup Steps 12.PNG]]  <br>
  
  /*Go to second line and display the key pressed*/
+
<b>STEP 14:</b> Now the device will be listed under libusb-win32 devices.
  LCD_GoToLineTwo();
+
[[FILE:UsbAsp Setup Steps 13.PNG]]  <br>
  
  while(1)
+
=Using XploreFlash(AVR Dudes)=
  {
+
      /* Read the key from Matrix Keypad */
+
  key=KEYPAD_GetKey();
+
  
  /* Display the Key Pressed */   
+
<b>STEP 1:</b>
  LCD_DataWrite(key);
+
Run the Xplore Flash(Avr Dudes) software and <br>
}
+
#Select the UsbAsp programmer from the dropdown as shown below.<br>
  }
+
#Select the AT89S52 controller from the drop down.<br>
 +
#Check the write option to flash the .hex file to the controller.<br>
 +
[[File:XploreFlash 01.png ]]  <br>
  
</syntaxhighlight>
+
<b>STEP 2:</b> Browse and Select the .hex file to be flashed.
 +
[[File:XploreFlash 02.png]]  <br>
  
=Downloads=
+
<b>STEP 3:</b> Finally hit the GO button to flash the .hex file.
Below are the links to download the old and new codes along with schematic diagrams.<br>
+
[[File:XploreFlash 03.png]] <br>
[https://github.com/ExploreEmbedded/8051_DevelopmentBoard New Code]<br>
+
[https://github.com/ExploreEmbedded/AT89S52_Ultra_Development_Kit Old Code and Schematics]
+
<br />
+
  
=Feedback=
+
<b>STEP 4:</b> Flashing status will be displayed in the conosle window.
Your comments motivate us to do better, your doubts and questions help us learn! Feel free to comment below
+
[[File:XploreFlash 04.PNG]]  <br>
{{DISQUS}}
+

Revision as of 10:09, 19 August 2016

In this tutorial, we will see how to use XploreFlash for flashing the hex files to AT89s52.
First, we will see how to install the XploreFlash software along with UsbAsp drivers and then continue with flashing the controller.

Installing UsbAsp Drivers

Download the UsbAsp drivers from this link and follow the below steps.
In case your are using Windows7/Vista/Xp, skip the first 7 steps and directly jump to step8.

Windows 8 and above do not allow the installation of drivers that are not digitally signed. This needs to be disabled by following the below steps.

STEP 1:Go to Advanced Start Options by searching the same in Windows Start Menu. UsbAsp Setup Steps.png

STEP 2: Click on Restart Now in Advanced Start Up options. UsbAsp Setup Steps 1.png

STEP 3: Now choose the Troubleshoot option. UsbAsp Setup Steps 2.jpg

STEP 4: Click on Advanced Options. UsbAsp Setup Steps 3.jpg

STEP 5: Click on StartUp Settings. UsbAsp Setup Steps 4.jpg

STEP 6: Now Click on Restart and wait till the PC restarts. UsbAsp Setup Steps 5.jpg

STEP 7: Once the PC restarts, Press 7/F7 to disable Driver Signature Enforcement. UsbAsp Setup Steps 6.jpg

STEP 8: Now Connect the Usbasp programmer to the system and it will be listed under other devices in device manager. UsbAsp Setup Steps 7.PNG

STEP 9: Right Click and choose Update Driver Software UsbAsp Setup Steps 8.png

STEP 10:Now browse and select the folder where the drivers are stored. UsbAsp Setup Steps 9.PNG

STEP 11: After selecting the driver folder, click on Next to install the drivers. UsbAsp Setup Steps 10.PNG

STEP 12: Click on <b>Install This Software Anyway UsbAsp Setup Steps 11.PNG

STEP 13: Once the installion is successful, below message will be displayed. UsbAsp Setup Steps 12.PNG

STEP 14: Now the device will be listed under libusb-win32 devices. UsbAsp Setup Steps 13.PNG

Using XploreFlash(AVR Dudes)

STEP 1: Run the Xplore Flash(Avr Dudes) software and

  1. Select the UsbAsp programmer from the dropdown as shown below.
  2. Select the AT89S52 controller from the drop down.
  3. Check the write option to flash the .hex file to the controller.

XploreFlash 01.png

STEP 2: Browse and Select the .hex file to be flashed. XploreFlash 02.png

STEP 3: Finally hit the GO button to flash the .hex file. XploreFlash 03.png

STEP 4: Flashing status will be displayed in the conosle window. XploreFlash 04.PNG