Method of converting 51 MCU program to AVR

Publisher:oplkjjjLatest update time:2019-10-28 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Summarize the conversion from C51 to ICCAVR 


1.
Replace the header files that define registers in C51, such as reg51.h and at89x51.h, with corresponding AVR header files such as io8515.h and io2313.h.

2. Interrupt handling function

In C51, the interrupt keyword is used to indicate that a function is an interrupt handling function. In ICCVAR, the #pragma interrupt_handler preprocessing command can be used to declare it at the beginning of the program. The specific usage is as follows: 
#pragma interrupt_handler
Note that the interrupt and using keywords in the original C51 source program should be deleted. 

3. Processing of bit and sbit data types in C51
ICCAVR does not support bit and sbit data types. Unsigned char can be used to replace these two types. The bit operations are processed using the standard C bit operation function. Online assembly processing can also be adopted. 

4. To initialize the interrupt system timer,
you need to re-assign the corresponding control register according to its function. The method is the same as C51. The details are as follows: the processing of TMOD TCON in MCS51 is changed to the processing of TCCR0 TCCR1A TCCR1B TIFR of AVR. 

The processing of IE IP in MCS51 is changed to
the processing of GIMSK TIMSK MCUCR SREG in AVR. The processing of IE IP in MCS51 is changed to the processing of GIMSK TIMSK MCUCR SREG in AVR. 

5. Change the original C51's handling of the external EEPROM of the watchdog circuit to the handling of the internal EEPROM of the watchdog circuit of the AVR chip. 

6. Change the initialization of MCS51UART to UCR and UBRR and initialized 

7. If an off-chip SRAM is used, the MCUCR should be initialized. If a pin is used as an output pin, its direction register should be initialized. 

8. In principle, the C language in C51 that complies with the ANSI standard does not need to be modified unless it is for the purpose of optimizing the program structure.

Reference address:Method of converting 51 MCU program to AVR

Previous article:ATmega16 microcontroller ad current and voltage sampling program
Next article:warning: #1295-D: Deprecated declaration spistar - give arg types

Recommended ReadingLatest update time:2024-11-16 15:47

Embedded Learning Notes 10——51 MCU Interrupt Timer Interrupt
1. Knowledge about CPU timing    (1) Oscillation period: The period of the oscillation source that provides the timing signal for the microcontroller (crystal oscillator period or external oscillation period).    (2) State cycle: Two oscillation cycles are one state cycle, represented by S. The oscillation cycle is
[Microcontroller]
Embedded Learning Notes 10——51 MCU Interrupt Timer Interrupt
51 single chip microcomputer serial port receiving and sending C51 program
//Crystal oscillator 11.0592Mhz //Revised on October 9, 2010 for netizens, debugged and passed on hardware #include reg52.h unsigned char a1; bit flag; void main() { TMOD=0x20; TH1=0xfd; TL1=0xfd; TR1=1; REN=1; SM0=0; SM1=1; EA=1; ES=1; while(1) {      if(flag==1)        {          ES=0;        
[Microcontroller]
ESP8266+51 MCU WIFI control multi-channel remote control switch program design
This is a design of a WIFI multi-channel remote control switch based on a single-chip microcomputer. It contains documents, programs, pictures and other materials. The actual picture is as follows:   The circuit schematic is as follows: Wifi switch component list 1) 9*15 multi-purpose board 2) STC89C52 microcontr
[Microcontroller]
ESP8266+51 MCU WIFI control multi-channel remote control switch program design
Realization of 74LS164 serial-input and parallel-output shift register based on 51 single-chip microcomputer
For the serial-in parallel-out shift register, the following is my personal understanding and experience gained from actual development projects. Figure 1: From the picture I drew above, we can get an 8-bit serial input and 8-bit parallel output. It can be seen that the high bit is shifted first, that is, the
[Microcontroller]
Realization of 74LS164 serial-input and parallel-output shift register based on 51 single-chip microcomputer
Design of train voice broadcasting system based on ISD4004 and AT89C51 microcontroller
In the modern industrial control process, working status and fault status alarm devices are widely used. They usually use sound and light to remind the operator to deal with the problems in time. With the development of new technologies, people have begun to apply voice technology to this field. It provides relevant i
[Microcontroller]
Design of train voice broadcasting system based on ISD4004 and AT89C51 microcontroller
51 MCU Study Notes 8 -- OLED Display (SPI)
1. Introduction to OLED Organic Light-Emitting Diode (OLED), also known as organic laser display or organic light-emitting semiconductor, was discovered by Chinese-American professor Ching W. Tang in a laboratory in 1979. OLED display technology has the advantages of self-luminescence, wide viewing angle, almost infin
[Microcontroller]
51 MCU Study Notes 8 -- OLED Display (SPI)
Design of smart home alarm system based on AT89C2051 microcontroller
introduction With the development of electronic information technology and computer network technology, the realization of home informatization and networking is a new trend in the development of smart home systems. As an important part of the smart home system, the performance of the alarm system is directly r
[Microcontroller]
Design of smart home alarm system based on AT89C2051 microcontroller
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号