找回密码
 注册
关于网站域名变更的通知
查看: 47|回复: 0
打印 上一主题 下一主题

LPC2132学习中遇到的常见问题

[复制链接]

该用户从未签到

跳转到指定楼层
1#
 楼主| 发表于 2024-4-1 11:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
自己写了一个头文件LCD.H,在其中定义了如下的全局变量:const int8 NoCheckBusy = 0;
) t; |8 K# C/ S, \( h6 Econst int8 CheckBusy = 1;
+ f1 j* t& W  v2 I
; |  Y8 r9 O3 o' dconst int32 LCD_RS = 1<<4;
' ?! q+ u1 i3 Z, H* iconst int32 LCD_RW = 1<<5;
8 u9 t. B" b% o* _. t0 Xconst int32 LCD_EN = 1<<6;( w  K4 ^8 V/ f( k) j
const int32 LCD_DATA = 0xff<<7;) ~9 e* P4 v) f

7 H6 y# {4 u+ _8 \( n在c文件lcd.c和main.c中都要用到,但是在编译的时候出现如下的问题:* U5 ?/ Q/ a3 X" S+ k7 m) {
Error: L6200E: Symbol NoCheckBusy multiply defined (by main.o and lcd.o).
8 ^3 o& ~6 e8 s+ L/ EError: L6200E: Symbol LCD_RS multiply defined (by main.o and lcd.o).
" _& k/ y/ `- d" Z9 a; ]( {, e4 P; c- R' O
上网站ARM.com/help/index.jsp?topic=/com.arm.doc.dui0435a/index.html" target="_blank">/zixunimg/eepwimg/infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0435a/index.html上去查找,有如下结果:. x) u( P4 t6 M% L$ ~  s
1 J( S4 `1 I7 d" m
L6200E:Symbol multiply defined (by and ).
& H8 K3 F, u0 t* [6 }There are two common examples where this occurs:
1 m5 }. C& a' Q! |  o' n( z; |1 Y, C1)Symbol __semihosting_swi_guard multiply defined (by use_semi.o and use_no_semi.o).
  N0 P1 l% T1 y/ q3 w! v/ H+ R0 {This error is reported when functions that use semihosting SWIs are linked in from the C library, in the presence of the__use_no_semihosting_swiguard. See the ADS 1.2 Compilers and Libraries Guide, section 4.2.2, "Building an application for a nonsemihosted environment" and ADS 1.2 Developer Guide, Section 6.10.1, "Linker error __semihosting_swi_guard".# F, O. i& f# n1 f# L7 w3 N/ I, A7 G
To resolve this, you must provide your own implementations of these C library functions.3 }* z! s+ j; A0 }4 [) O/ s3 H1 D
The ADS 1.2 Examplesembedded directory contains examples of how to re-implement some of the more common SWI-using functions - see the fileretarget.c.' `0 W) b9 f  a
To identify which SWI-using functions are being linked-in from the C libraries:1 ]- ^7 N( Y) I) \7 ]5 c
1. Link with armlink -verbose -errors err.txt% w4 Q+ {0 u0 G/ r0 F
2. Search err.txt for occurrences of __I_use_semihosting_swi
5 D% S7 D  h3 [7 rFor example:4 t, J& q6 g( {3 Z0 \: k+ {
:
- a3 Z+ b7 v9 M% @8 V  VLoading member sys_exit.o from c_a__un.l.6 M. I9 `; ^& t
reference : __I_use_semihosting_swi  m4 @. @' E  d0 k
definition: _sys_exit: n2 f- d5 y" Y7 M  J* \& B( ?
:
0 F, n; j5 y" W$ nThis shows that the SWI-using function _sys_exit is being linked-in from the C library. To prevent this, you will need to provide your own implementation of this function.
' R8 A% J! e  J8 Q2)Symbol __stdout multiply defined (by retarget.o and stdio.o)., s9 p3 g1 v, z. F
This means that there are two conflicting definitions of__stdoutpresent – one inretarget.o, the other instdio.o. The one inretarget.ois your own definition. The one instdio.ois the default implementation, which was probably linked-in inadvertently.2 b& k4 q" Z: _) J8 C0 `5 w/ I
stdio.ocontains a number symbol definitions and implementations of file functions likefopen,fclose,fflush, etc.stdio.ois being linked-in because it satisfies some unresolved references.+ I8 B5 Q  [4 v5 \
To identify why stdio.o is being linked-in, you must link with the linkers "verbose" switch, e.g.:
3 D9 R, M& _) ~, E4 S% P2 Zarmlink [... your normal options...] -verbose -errors err.txt
. r% I/ W! r  N( d0 fThen studyerr.txt, so see exactly what the linker is linking-in, from where, and why.( B! ~% p* C' E8 W
To move forward, the user may have to either:+ e* Q3 g- M% {9 k* c
- Eliminate the calls likefopen,fclose,fflush, etc, or
. S# ?- B* d* ~( p, t  r- Re-implement the_sys_xxxxfamily of functions.4 q5 H: {5 L  l  p$ [# H3 Z! @* C8 y
See the ADS 1.2 Compilers and Libraries Guide, section 4.10, "Tailoring the input/output functions".
( y- ~5 ]. V  E% Q4 R具体是什么意思看的也不是很懂,后来看了别人的解决方法是:在头文件中仅声明变量,而把变量的定义都放到c文件中去,问题就解决了。& }- q; B- ]; _) W5 u* v
即把
0 Q" Y  A! c. w- ~. J4 ]  |
9 }8 x4 i, `( a2 a/ M# mconst int8 NoCheckBusy = 0;
! P& _1 B4 ]9 y3 H" Mconst int8 CheckBusy = 1;
6 @8 P  [/ m# l" A$ j0 V) O5 t  O
const int32 LCD_RS = 1<<4;
. C- [! J, i/ zconst int32 LCD_RW = 1<<5;
) y0 ]& P( t) }8 ~4 w2 Bconst int32 LCD_EN = 1<<6;; Q' R% S' ]# K# u2 H7 I
const int32 LCD_DATA = 0xff<<7;
" R) W! x* W2 E0 O1 R% f7 l6 K
都放到lcd.c中就可避免该问题,时间不多,具体原因还有待研究。- y' f& t# p6 w8 @. X. v
$ H/ C8 {6 }3 ?# F

0 p: ^* a! A# C+ B在使用ADS1.2编译程序的过程中,我们有函数如下定义:void PutStr(uint8 x, uint8 y, uint8* str);# z$ X+ L0 Y3 C& C6 k8 o0 |7 I; N+ e
我们在主函数中有这样的用法:* n. L! }0 \2 [9 a3 ]0 V+ g
PutStr(0, 0, "Hello world!");! f2 x1 r7 i% Z' b/ L
经编译后,有如下错误:
' t& C) k9 O+ V" @8 u8 k) VError: C3028E implicit cast of pointer to non-equal pointer
; Q& h1 ]; K* Y& p8 I* A! j9 j( P  T
解决方法如下:5 y" {! \/ w( b7 }
PutStr(0, 0, (uint8*)"Hello world!");
8 |2 `& B) X5 p3 \6 f0 T. ^即将我们的字符串强制转换为我们在函数中所定义的形式。
% K( c. [( `. `
. W0 Z* ]. D5 \5 J6 e& ]PS:
/ y9 R4 k: n2 T$ P
C3028E: implicit cast of pointer to non-equal pointer
C3029E: implicit cast of non-0 int to pointer
C3030E: implicit cast of pointer to int
C3031E: implicit cast of to int
Try re-writing the code to avoid the implicit cast, e.g. add an explicit cast.
5 G8 y3 Z9 d. l/ b) X0 j) yThese errors can be suppressed with "-Ec".
, {( z/ \! c  I/ o* r3 r
0 U; h8 M! d- a" B! v  M$ B

: @6 v& I' v% W7 z% I8 P& |  N- p: u1 f0 A! u) |
. d, Y( e" R2 T* r- q  J( M
1 I5 T$ J7 k; e3 o

/ A. k# S/ P  g8 \
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-8-23 21:35 , Processed in 0.109375 second(s), 23 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表