Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to consider the time parameter when C5 1 program is converted into AVR program?
How to consider the time parameter when C5 1 program is converted into AVR program?
If it is C language, the limited keywords will be changed, the header file will be rewritten, and some writing methods of functions will be changed. There are many compilers for AVR, and each compiler has its own unique writing method. If you understand the compiler first and then transplant it, the success rate will be higher.

In addition, you should first choose a good compiler, such as GCC, ICC, CVAVR, IAR, etc. It depends on the compiler you choose and the assembly compiler, such as AVR.

Studio.

You don't need to write your own header file. Each compiler has its own header file, just #include, but include it correctly.

Matters needing attention in transplanting 5 1 single chip microcomputer (including STC) program to AVR platform

1)

Header file,

The register name and register setting code should be modified accordingly.

2)

The bit operation of IO port should also be adjusted accordingly.

3)

The format of the interrupt service function is also different, so it needs to be adjusted accordingly.

4)

The reset value of the port register of 5 1 single chip microcomputer is 1, so when it is used as an output port, even if it is not set in the program, it will output a high level.

And port registration in AVR microcontroller.

PORTX

The reset value is 0,

Therefore, when transplanting the program of 5 1 single chip microcomputer to avr single chip microcomputer, we must pay attention to the port initialization code.

Assuming that initialization is not performed in the 5 1 program, the port defaults to high.

In avr, if the original program is copied, the port will become low level, which may cause the system to fail to operate normally and it is difficult to find out the problem.

5)

Because they have different ways to store long byte data, from address to high address,

High bytes and low bytes are stored in sequence on the 5 1 platform.

The low byte and the high byte are sequentially stored in the AVR,

Therefore, if the program involves using combined or sequential access memory addresses to separate long byte data, you need to pay attention to whether the high byte or the low byte is read in the low address. For example:

alliance

UNI _ byte

uint

dat

Ucal

tab[2];

} wdat

In this complex wdat,

The member dat is an integer with a length of 2 bytes.

Then wdat.tab[0] represents the byte of dat low address, if it is in keil.

In c language,

Because that specify low address stores high byte,

Then wdat.tab[0] is the high byte of dat;

If it is in IARAVR or ICCAVR, because the low-order address stores low-order bytes,

Then wdat.tab[0] is the low byte of dat.