AT89S5X Offline Downloader Production

Publisher:心灵的旅程Latest update time:2012-10-24 Source: 21ic Keywords:AT89S5X  AT89S52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Recently, due to work needs, I am preparing to make an offline downloader for AT89S5X. The initial consideration is to use AT89S52 as the host and write the target code into AT24C64 through the serial port (AT24C64 has 8K space, just enough for 52). After arriving at the site, the code in the EEPROM can be written into the target microcontroller through the host through the simulated ISP timing to achieve offline download.

Before drawing the schematic, I planned to figure out the ISP timing of S5X. When I first started reading the English document, I was so confused... I mistook the high-bit transmission for the low-bit transmission selection... I spent two days without realizing it... Because the AT document was not clear about ISP (at least in my opinion), I searched the source code of USBASP on the Internet and referred to the ISP timing of S5X in it, and finally understood it... Here are some key points about the ISP timing programming of S5X:

1: About reset timing

RST = 1;
SCK = 0;
DELAY(1);
RST = 0; //Note that there is a pull-down process
DELAY(1);
RST = 1;
DELAY(1);

2: Connect to the computer to check whether to enter the ISP programming mode

ISP_WR(0XAC);
ISP_WR(0X53);
ISP_WR(0X00);
TempData[3]=ISP_WR(0X00); //The fourth byte is written and read at the same time. If the data is 0X69, it means that the

In ISP mode

3: Regarding the read identification word, before the Erase command was tested, the data just read out was normal (1E 52 06). Later, when testing the Erase command, I suspected that
the Erase delay time was too short. Unfortunately, the read value was always 1F 7F 1F.

ISP_WR(0X28);
ISP_WR(0X00);
ISP_WR(0X00);
TempData[0] = ISP_WR(0X00); //1E

ISP_WR(0X28);
ISP_WR(0X01);
ISP_WR(0X00);
TempData[1] = ISP_WR(0X00); //52

ISP_WR(0X28);
ISP_WR(0X02);
ISP_WR(0X00);
TempData[2] = ISP_WR(0X00); //06

4: Regarding the Erase command, the delay I found on the Internet is about 500MS. I haven't tested it specifically yet. I will test and determine the delay
parameters after the entire program function is complete.

5: About ISP pin connections:

MOSI: Master out, slave in

MISO: Master in, slave out

SCK/RST: This should be self-explanatory
==================================================
The following is my test program.
=============================================
/**********************************************************
S5X ISP test program
**********************************************************/
#include
#include "1602.h"

sbit RST = P2^3;
sbit MISO = P2^2;
sbit MOSI = P2^1;
sbit SCK = P2^0;

ISP_WR(uchar command);
ISP_RD();
void DELAY(uint temp);


void main()
{
uchar TempData[4];

P0 = 0XFF;
P1 = 0XFF;
P2 = 0XFE;
P3 = 0XFF;

Lcd_Init();

MOSI = 1;
MISO = 1;
RST = 1;
SCK = 0;
DELAY(1);
RST = 0; //Note
DELAY(1) here;
RST = 1;
DELAY(1);


ISP_WR(0XAC);
ISP_WR(0X53);
ISP_WR(0X00);
TempData[3]=ISP_WR(0X00); //Connection test

/* //Write test
ISP_WR(0X40
);
ISP_WR(0X00);
ISP_WR(0X00); ISP_WR(0XA5);
DELAY(5000);
*/
/*
ISP_WR(0XAC); //Erase test
ISP_WR(0X80);
ISP_WR(0X00);
ISP_WR(0X00);
DELAY(5000);
*/

ISP_WR(0X28);
ISP_WR(0X00);
ISP_WR(0X00);
TempData[0] = ISP_WR(0X00); //1E

ISP_WR(0X28);
ISP_WR(0X01);
ISP_WR(0X00);
TempData[1] = ISP_WR( 0X00); //52

ISP_WR(0X28);
ISP_WR(0X02); ISP_WR(0X00
);
TempData[2] = ISP_WR(0X00); //06
/*
ISP_WR(0X20); //Read test
ISP_WR(0X00);
ISP_WR(0X00);
TempData[3] = ISP_WR(0X00);
*/
//******************************************************The following is the data sent to LCD1602
for displayif((TempData[0] >>4) >9) Lcd_Out(Data,(TempData[0]>>4)+0x37);
else Lcd_Out(Data,(TempData[0]>>4)+0x30);
if((TempData[0] & 0x0f) >9) Lcd_Out(Data,(TempData[0] & 0x0f)+0x37);
else Lcd_Out(Data,(TempData[0] &0x0f)+0x30);

if((TempData[1] >>4) >9) Lcd_Out(Data,(TempData[1]>>4)+0x37);
else Lcd_Out(Data,(TempData[1]>>4)+0x30);
if ((TempData[1] & 0x0f) >9) Lcd_Out(Data,(TempData[1] & 0x0f)+0x37);
else Lcd_Out(Data,(TempData[1] &0x0f)+0x30);

if((TempData[2] >>4) >9) Lcd_Out(Data,(TempData[2]>>4)+0x37);
else Lcd_Out(Data,(TempData[2]>>4)+0x30);
if ((TempData[2] & 0x0f) >9) Lcd_Out(Data,(TempData[2] & 0x0f)+0x37);
else Lcd_Out(Data,(TempData[2] &0x0f)+0x30);

if((TempData[3] >>4) >9) Lcd_Out(Data,(TempData[3]>>4)+0x37);
else Lcd_Out(Data,(TempData[3]>>4)+0x30);
if ((TempData[3] & 0x0f) >9) Lcd_Out(Data,(TempData[3] & 0x0f)+0x37);
else Lcd_Out(Data,(TempData[3] &0x0f)+0x30);
while(1);
}


ISP_WR(uchar DATA)
{
uchar i,Rec_Data;

for(i=0;i<8;i++)
{
MOSI = DATA& 0x80;
DATA= DATA<<1;

Rec_Data = Rec_Data << 1;
if(MISO == 1) Rec_Data |= 0x01;

SCK = 1;
DELAY(1);
SCK = 0;
DELAY(1);
}
return(Rec_Data);
}


void DELAY(uint temp)
{
uint i,j;
for(i=0;i for(j=0;j<30;j++);
}

Keywords:AT89S5X  AT89S52 Reference address:AT89S5X Offline Downloader Production

Previous article:ds18b20 temperature measurement system based on single chip microcomputer
Next article:51 MCU controls K9K8G08U0C NAND Flash read and write program

Recommended ReadingLatest update time:2024-11-16 18:07

Design of electronic alarm clock based on AT89S52 single chip microcomputer
1. System Function Requirements The task requirements of the computer clock are: once the system is running, it starts timing from 00:00:00, and displays the current values ​​of hours, minutes, and seconds on the digital tube. 2. System Overall Plan 1. Clarify the tasks Basic working principle: ever
[Microcontroller]
Design of electronic alarm clock based on AT89S52 single chip microcomputer
Design of Dual Fuzzy Temperature Controller Based on AT89S52
In modern industrial control, temperature control is very important and increasingly complex. Due to the characteristics of temperature control such as nonlinearity, large lag, time-varying, and unidirectional temperature rise, it is difficult to establish an accurate mathematical model in practical applications, and i
[Microcontroller]
Design of Dual Fuzzy Temperature Controller Based on AT89S52
AT89S52 MCU simulates I2C bus protocol to read and write AT24C04
      The I2C bus is a 2-wire bus. The data line is SDA and the clock line is SCL. The structure is simple.        AT24C04 is an EEPROM with an I2C bus interface. The size is 512*8 bits. The MCU AT89S52 itself does not have an I2C bus interface, so a program can be written to use the parallel port to simulate the I2C
[Microcontroller]
Design of a New Multi-rate Single-phase Watt-hour Meter
  1 Introduction   As the demand for electricity increases, the phenomenon of uneven electricity consumption in different time periods is becoming more and more serious. In order to reasonably regulate the power load and save energy, power companies have begun to encourage the use of multi-rate electricity meters. T
[Microcontroller]
Design of a New Multi-rate Single-phase Watt-hour Meter
Design of password lock based on single chip microcomputer control (including circuit diagram and source program)
Design of a password lock controlled by a single-chip microcomputer. The P1 pin of the AT89S52 single-chip microcomputer is connected to independent buttons S1-S8, which represent the number keys 0-5, the confirmation button, and the cancel button respectively. The single-chip microcomputer outputs 4 signals from P3
[Microcontroller]
Design of password lock based on single chip microcomputer control (including circuit diagram and source program)
Design of a simple automatic control principle experimental system
  1 Introduction   The principle of automatic control is the most important professional course in the automation major of domestic universities. This professional course is very theoretical, and classroom teaching alone cannot achieve the ideal teaching effect. Therefore, all universities have set up experiments on
[Microcontroller]
Design of a simple automatic control principle experimental system
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号