First, the problem of duplicate definition in IAR
When you write your own header file, remember to define the constants in the. c file, and if you define the constants in the. h file, the constants in the header file will be defined in the package when the header file is included in the MAIN.C or elsewhere. Included in the MAIN.C, at the same time, the corresponding. c file also has the constant definition statement, will cause linker error, there is xxxx redefinition (redefined). Also, when you want to use the amount defined in the other. c file in Main.c, remember the + extern+ < type >+<+ variable name >.
Standard practice: Declare variables in the. h file, define variables in a. c file, and other. c files to use the variable as long as it contains the. h header file, equivalent to the variable declaration, you can refer to the variables defined in the other. c files. In general, variables are only declared in the header file, and variables are defined in the original file, even if you use precompiled directives in the header file #ifndef ... #endif, and you cannot define variables in the header file. cannot be defined, must be declared.
Second, program overflow problem (error[lp011] problem)
ERROR[LP011]: section placement failed:unable to allocate space for sections/blocks with a total estimatedminimum size of 0x2ba9 bytes In<[0x008000-0x009fff]>
Reason: Change the library from full to normal, all of a sudden space to reduce a lot, and printf and scanf format from full to small, but this can not be used in printf.
(Total uncommitted space 0x1f80).
971 bytes of ReadOnly codememory
915 bytes of readonly data memory
726 bytes of ReadWrite data memory
Errors:1
CPU:STM8S103F3P, which has 8 K FLASH[0X008000-0X009FFF], has 1 K RAM, the actual hint of the FLASH size is 10582+809>8192
[0x008000-0x009fff]=8192,0x1f80=8064
0x3180=12672, 0x1f80=8064, 11971+915=12886
8s207 There is no problem, replaced by 103 problems will overflow.
Related discussions:
Http://www.amobbs.com/thread-5516889-1-26.html
Http://www.amobbs.com/thread-5516388-1-1.html
Http://www.amobbs.com/thread-5526431-1-1.html
Http://www.amobbs.com/thread-4181924-1-1.html
Three, error[pe169]: Expecteda declaration
Answer: more} closing curly braces.
Four, the PL2303 power after the mouse moves the solution method:
1, re-power, because we developed the board with a button to download the circuit, so the first power on, will cause several times (3~6) MCU reset, very normal. You do not have to press the power button every time to achieve the reset, there is no problem.
2, because your routine, a power, through the serial port output data, and at this time CH340 still in and computer communication, CH340 in and computer USB connection established, received data, it may lead to your serial port is not recognized as the serial port, and was recognized why ball and other equipment, so that the mouse flying.
Workaround:
Before power on, press and hold the MCU reset, then power on. Wait about 10 seconds before releasing the reset. It's all OK.
Common errors in stm8s and IAR programs