Introduction to ISP online programming design of single chip microcomputer

Publisher:创意驿站Latest update time:2012-08-08 Source: 九江学院 Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

With the development of electronic technology, the scale of chips is getting larger and larger, and the packaging is becoming smaller and smaller. Correspondingly, the difficulty of system board-level debugging is also increasing. In the traditional debugging method, frequent debugging and program replacement require frequent plugging and unplugging of chips, and the development efficiency is extremely low. The ISP online programming technology provided by the AT89S series of microcontrollers has completely changed the traditional development model. When developing the microcontroller system, the pins of the chip will not be damaged, which accelerates the listing of products and reduces R&D costs, shortens the time from design, manufacturing to on-site debugging, simplifies the production process, and greatly improves work efficiency. Therefore, it is an economical and effective way to upgrade and maintain market-standard products on-site, which greatly promotes the development of PLD products.

1 PC parallel port

1.1 Introduction to Parallel Port Hardware Interface

The standard parallel port has 25 pins, of which data port pins are 2 to 9, status port pins are 15, 10 to 13, control port pins 1, 14, 16, 17 are used to connect devices, and the other pins 18 to 25 are ground pins GND. The 25-pin parallel port is shown in Figure 1.

Click here to view the image in a new window
Figure 1 25-pin parallel port

The parallel port works in SPP mode, and the PC controls them by reading or writing three 8-bit port registers. The port registers are:

◆ The data port (address 0x378) is D7~D0, corresponding to pins P9~P2;
◆ The status port (address 0x379) is S7~S3, corresponding to pins P11, P10, P12, P13, P15;
◆ The control port (address 0x37A) is C3~C0, corresponding to pins P17, P16, P14, P1.

Note: The logic state of the S7, C0, C1, and C3 signals at the connector is opposite to the corresponding register bits. When writing to these bits, the written value should be opposite to the value set at the connector; similarly, when reading, the read value should also be opposite to the value set at the connector.

1.2 Introduction to Parallel Port Programming

Windows has adopted a shielding strategy for the underlying system operations. However, in hardware or system software development, as long as the underlying system operations are involved, you have to go deep into the Windows kernel to write system-level device drivers. This is the case for parallel port read/write operations. In order to bypass the Windows security protection mechanism, it is necessary to allow 32-bit Windows programs to directly operate the I/O port. Here, several functions in the WinIo library written by Yariv Kaplan are used to implement the read/write of the I/O port.

(1) Initialization and termination
The port must be initialized and terminated before and after reading/writing.
InitializeWinIo();
ShutdownWinIo();

(2) Installation and uninstallation
If the operating system is Windows 98 or Windows 95, you need to call the driver function.
InstallWinIoDriver(PSTR pszWinIoDriverPath, bool IsDemandLoaded = false);
RemoveWinIoDriver();

(3)  读/写I/O口
GetPortVal(WORD wPortAddr, PDWORD pdwPortVal, BYTE bSize);
SetPortVal(WORD wPortAddr, DWORD dwPortVal, BYTE bSize);

The GetPortVal function reads a BYTE/WORD/DWORD value from the specified port; the SetPortVal function writes a BYTE/WORD/DWORD value to the specified port; wPortAddr specifies a port address value; pdwPortVal is a pointer to a double-byte variable that stores the value read from the wPortAddr port; dwPortVal is a double-byte variable written to the wPortAddr port; bSize specifies the number of bytes to read, and the value can be 1, 2, or 4.

2 AT89S5X series microcontroller

2.1 Introduction to AT89S51

AT89S51 is a low-power, high-performance CMOS 8-bit single-chip microcomputer, with 4 KB ISP (InSystem Programming) Flash read-only program memory that can be repeatedly erased and written 1,000 times. The device is manufactured using Atmel's high-density, non-volatile storage technology, compatible with the standard MCS51 instruction system and 80C51 pin structure, and integrates a general-purpose 8-bit central processor and ISP Flash storage unit in the chip. The powerful AT89S51 can provide cost-effective solutions for many embedded control application systems.

2.2 AT89S51 serial programming timing and instructions

2.2.1 Timing Analysis in Serial Programming Mode

Click here to view the image in a new window

2.2.2 Serial Programming Instructions

Serial programming uses a 4-byte protocol and the instructions are listed in Table 1.

Table 1 Serial programming instructions
Click here to view the image in a new window

[page]

3 Parallel port and AT89S5X single chip microcomputer hardware design

Through the analysis of parallel port and programming timing, we made the ISP download line of AT89S5X microcontroller. The following is a brief introduction to the connection between parallel port and microcontroller: parallel port P2 pin is connected to the microcontroller P1.5 pin (MOSI); parallel port P10 pin is connected to the microcontroller P1.6 pin (MISO); parallel port P1 pin is connected to the microcontroller P1.7 pin (SCK); parallel port P17 pin is connected to the microcontroller RST pin, as shown in Figure 2.

Click here to view the image in a new window
Figure 2 AT89S52 download line circuit diagram

4 ISP download line software design

Based on the hardware design, the download line program was written using Visual C++6.0 through the analysis of ISP timing and serial programming instructions. Its main key programming functions are omitted - Editor's note.

Conclusion

The following are some parameters obtained by the author during debugging, I hope it will be helpful to everyone.

References:

The frequency of the crystal oscillator is 33 MHz (MAX), so the period T=1/F=1/33 MHz=30 ns (MIN); the positive pulse width of SCK is 8×30 ns=240 ns (MIN); the negative pulse width of SCK is 8×30 ns=240 ns (MIN); the time from MOSI establishment to SCK becoming high is 30 ns (MIN); the MOSI hold time after SCK becomes high is 2×30 ns (MIN); the time from SCK becoming low to MISO being valid is 10 ns (MIN) ~ 32 ns (MAX) (generally 16 ns); the chip erase instruction cycle is 500 ms; the serial byte write cycle is 64×30 ns+400 ns.

Experimental data:

The frequency of the crystal oscillator is 33 MHz (MAX), so the period T = 1/F = 1/33 MHz = 30 ns (MIN); the chip erase instruction period is 200 ms; the MOSI hold time after SCK goes high is 1 ms (MIN)

Keywords:MCU Reference address:Introduction to ISP online programming design of single chip microcomputer

Previous article:Introduction to Graphical Programming Methods for Single Chip Microcomputers
Next article:Diagram of time units inside the microcontroller

Recommended ReadingLatest update time:2024-11-16 22:48

Hardware debugging skills during MCU development
In the process of single-chip microcomputer development, from hardware design to software design, almost all of them are completed by the developer himself according to the characteristics of the system. Although this can reduce system costs and improve system adaptability, the debugging of each system takes up 2/3 of
[Analog Electronics]
The microcontroller obtains a 16-bit data packet from the serial port
Description: First get the high byte, then save it in a 16-bit variable, then shift left 8 bits, then get the low byte data and add it to the 16-bit variable to get a 16-bit data.   //Serial port gets 16-bit data u16 get_uart_data16(u16 *rece) {     u8 temp;     while(!get_uart_data(&temp));     *rece = (u16)temp;    
[Microcontroller]
ETAS and Infineon’s ESCRYPT CycurHSM based on AURIX microcontrollers obtains NIST CAVP certification
The encryption algorithm suite of ETAS , a leading software-defined vehicle (SDV) solution provider, and Infineon Technologies AG successfully passed certification. The certificate was validated under the National Institute of Standards and Technology's (NIST) Cryptographic Algorithm Validation Program (CAVP) a
[Embedded]
ETAS and Infineon’s ESCRYPT CycurHSM based on AURIX microcontrollers obtains NIST CAVP certification
Design of automatic horn tone player based on AT89C51 microcontroller
1 Introduction The daily routine of institutions and colleges requires timing and beep prompts. The author uses AT89C51 microcontroller and LM386 audio power amplifier to form an automatic timing and beep player. It is low cost, effective and worthy of promotion. 2 Main features and pin functions of AT89C51 AT89
[Microcontroller]
The memory of MCS-51 can be divided into four categories. Detailed explanation of 51 single-chip microcomputer memory
        The memory of MCS-51 can be divided into four categories:         Program Memory         A microprocessor can intelligently perform a task. In addition to its powerful hardware, it also needs the software it runs. In fact, microprocessors are not smart. They just execute the program written by people in ad
[Microcontroller]
The memory of MCS-51 can be divided into four categories. Detailed explanation of 51 single-chip microcomputer memory
PIC microcontroller controls CC1101 to realize loral wireless transmission source program
The microcontroller source program is as follows: #include pic.h __CONFIG(0x3B31); #include "board.h" /* MAIN.C file * * Copyright (c) 2002-2005 STMicroelectronics */ //#include "OLED.h" /*typedef unsigned char INT8U; typedef signed char INT8S; typedef unsigned int INT16U; typedef signed int INT16S; typedef unsigned
[Microcontroller]
Easy Introduction to MCU Part 2: Flowing Light
Since there is no pull-up resistor inside the P0 port, an external pull-up resistor is required when P0 is used as input or output, usually around 10k. The procedure is as follows: #include reg52.h //header file #define uchar unsigned char #define uint unsigned int //macro definition uchar code table ={0xfe,0xfd,0
[Microcontroller]
Easy Introduction to MCU Part 2: Flowing Light
Six important parts of microcontroller learning and application
1. Bus A circuit is always made up of components connected by wires. In analog circuits, wiring is not a problem because the devices are generally in serial relationship and there are not many wires between the devices. However, computer circuits are different. They are based on microprocessors. All devices must be
[Power Management]
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号