关于C语言地址指针的问题

shanghai   2004-8-31 16:05 楼主
比如C51可作如下定义:
 code uchar x[4]={ //x定义在代码区
0x01,0x02,
0x03,0x04,
};
uchar xdata *p            //指针P定义在外部RAM
#define pflag XBYTE[0x0200] //pflag定义在外部RAM 200H处
#define Px((unsigned char volatile *) 0x20800L) //指针PX指向外部RAM 800H

请问MSP430利用C语言对以上定义如何实现
敬请指教

回复评论 (13)

const unsigned char Add[]={0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA};
点赞  2004-8-31 16:13
加入语句:
   const unsigned char 0x2300[]={0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA};
编译后提示如下(是哪里出错):
Making target Debug...
fet140_ta01.c
c:\program files\iar systems\ew23\430\fet_examples\fet140\c\fet140_ta01.c (42) : Error[16]: Identifier expected
c:\program files\iar systems\ew23\430\fet_examples\fet140\c\fet140_ta01.c (42) : Warning[14]: Type specifier missing; assumed "int"
c:\program files\iar systems\ew23\430\fet_examples\fet140\c\fet140_ta01.c (42) : Error[112]: ',' unexpected
c:\program files\iar systems\ew23\430\fet_examples\fet140\c\fet140_ta01.c (42) : Error[109]: ';' unexpected
Total number of errors: 3
Total number of warnings: 1
点赞  2004-8-31 16:28
const unsigned char name[] @ 0x1000 ={0x00,0x00,.......};
点赞  2004-8-31 16:48
编译出错提示:
Making target Debug...
fet140_ta01.c
c:\program files\iar systems\ew23\430\fet_examples\fet140\c\fet140_ta01.c (32) : Error[8]: Invalid character encountered: '@'; ignored
c:\program files\iar systems\ew23\430\fet_examples\fet140\c\fet140_ta01.c (32) : Error[32]: Invalid declaration syntax
c:\program files\iar systems\ew23\430\fet_examples\fet140\c\fet140_ta01.c (32) : Error[16]: Identifier expected
c:\program files\iar systems\ew23\430\fet_examples\fet140\c\fet140_ta01.c (32) : Warning[14]: Type specifier missing; assumed "int"
c:\program files\iar systems\ew23\430\fet_examples\fet140\c\fet140_ta01.c (32) : Error[112]: ',' unexpected
c:\program files\iar systems\ew23\430\fet_examples\fet140\c\fet140_ta01.c (32) : Error[109]: ';' unexpected
Total number of errors: 5
Total number of warnings: 1
包含#include <msp430x14x.h> 是否还要包含其它文件
点赞  2004-8-31 17:02
你用的是哪个版本?
点赞  2004-8-31 17:06
2.31E
点赞  2004-8-31 17:13
是否没定义长度啊!!
如:
CONST UNSIGNED CHAR XXX[3]={0x11,0x22,0x33};
点赞  2004-8-31 20:28
跟数组长度无关,不知是否如lsdfae04所说跟EW版本有关,编译软件不认识@,如是该装哪个版本,哪里下载,多谢了!
点赞  2004-9-1 08:56
到http://www.iar.com  下载最新的3.20A版本。
点赞  2004-9-1 08:59
能否提供默认的参CDKEY
点赞  2004-9-1 10:55
IAR会发给你的
点赞  2004-9-1 11:57
安装3.20A后原来的程序居然编译不通过
interrupt[TIMERA0_VECTOR] void Timer_A (void)
{
P1OUT ^= 0x01;
CCR0 += 50000;
}
不认识interrupt
头文件:#include <msp430x14x.h>
设置:Options-->linker-->confi-->linker command file 选择
$TOOLKIT_DIR$\CONFIG\lnk430F149.xcl
是否哪里设置不对,程序在原来版本下调试通过应该不会有问题。
点赞  2004-9-3 16:44

版本不同中断书写格式也不同

INTERRUPT FUNCTIONS AND VECTORS
The syntax for defining interrupt functions changed from version 1.x.
Version 1.x syntax
The syntax when defining interrupt functions using version 1.x:
interrupt [vector] void function_name(void);
where vector is the vector offset in the vector table.
Version 2.x syntax
The syntax when defining interrupt functions using version 2.x:
#pragma vector=vector
__interrupt void function_name(void);
where vector is the vector offset in the vector table.
点赞  2004-9-4 09:24
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复