Microchip
直播中

吴晓成

7年用户 362经验值
私信 关注
[问答]

构建包含ASM模块的C代码的错误

我正在尝试为Wire Maxim协议构建App Note AN1199。这是一个带有几个头文件的单个源代码文件。其中的一个头具有软件设计用于PIC的include文件,因此我把它更改为PIC(24FJ64GB002)。另一个头文件有一些ASM模块。一个例子是:当我尝试构建时,我得到了一些提示未声明的_asm函数的错误,但是我无法找出任何错误。很多年前,我只尝试过几行汇编,但我认为我的大脑把这些记忆封闭起来作为某种防御机制。以下是错误信息:执行:“C:Program FilesMicro.MPLAB C30binpic30-gcc.exe”-mcpu=24FJ64GB002-x c-c“1-Wire App Note Source Code1..c”-o“1..o”-D_DEBUG-g-WallIn文件,包括在1-线应用说明源码1-线应用注释源代码\1Wi线源码\1Wi线应用源码\1wire1Wi线应用源码\1wire1Wi线应用源码1wire1..c:45:45:1-1-线应用说明源码\1.App布线应用说明源码\\1..45:45:45:1:1:1:1:1:1:1-线应用说明源码1-线应用说明源码\未申报首先在这个函数中使用)1-Wire App Note Source Code1..c:115:error:(每个未声明的标识符只报告在1-Wire App Note Source Code1..c:115:error:对于每个函数它出现在。)1-Wire App Note Source Code1..c:115:error:movlw'1-Wire App Note Sou之前的语法错误rce Code1..c:120:error:在“movlw”1Wire App Note Source Code1..c:124:error:在“movlw”1-Wire App Note Source Code1..c1..c:In function'OW_write_bit:1-Wire App Note Source Code1..c:120:error:“_asm”之前的语法错误(在此函数中首次使用)1-Wire App注意,源代码1..c:147:error:在“movlw”1-Wire App Note Source Code1..c:149:error:在“movlw”1-Wire App Note Source Code1..c:155:error:在“movlw”1-Wire App Note Source Code1..c:147:error:在“movlw”1-Wire Ap Ap之前的语法错误p Note Source Code1..c:在函数'OW_read_bit':1-Wire App Note Source Code1..c:176:error: '_asm'unsclared(在这个函数中首次使用)1-Wire App Note Source Code1..c:176:error:movlw'1-Wire App Note Source Code1..c:178:error:movlw'1-1.'1之前的语法错误-Wire App Note Source Code1..c:182:error:movlw'1之前的语法错误-Wire App Note Source Code1..c:230:95:warning:文件末尾没有换行

以上来自于百度翻译


      以下为原文

    I'm trying to build the App Note AN1199 for 1 Wire Maxim Protocol.

This is a single source code file with a couple of header files. One of these headers has the include file for the PIC that the software was designed for, so I changed it to my PIC (24FJ64GB002). Another of the header files has some ASM modules. A sample being :
#if(CLK_FREQ_25000000)
  #define wait(a) _asm movlw a
       movwf macro_delay,1
     loop: nop
       nop
       nop
       decfsz macro_delay,1,1
       bra loop
      _endasm
      
  #define BAUD_RATE 39
When I try to build I get errors suggestive of undeclared _asm functions, but I can't figure any of it out. I only attempted a few lines of Assembly , many years ago but I think my brain shut those memories out as some sort of defensive mechanism.Here's the error messages:
Executing: "C:Program FilesMicrochipMPLAB C30binpic30-gcc.exe" -mcpu=24FJ64GB002 -x c -c "1-Wire App Note Source Code1wire.c" -o"1wire.o" -D__DEBUG -g -Wall
In file included from 1-Wire App Note Source Code1wire.c:45:
1-Wire App Note Source Code/1wire.h:23:7: warning: no newline at end of file
1-Wire App Note Source Code1wire.c: In function 'OW_reset_pulse':
1-Wire App Note Source Code1wire.c:115: error: '_asm' undeclared (first use in this function)
1-Wire App Note Source Code1wire.c:115: error: (Each undeclared identifier is reported only once
1-Wire App Note Source Code1wire.c:115: error: for each function it appears in.)
1-Wire App Note Source Code1wire.c:115: error: syntax error before 'movlw'
1-Wire App Note Source Code1wire.c:120: error: syntax error before 'movlw'
1-Wire App Note Source Code1wire.c:124: error: syntax error before 'movlw'
1-Wire App Note Source Code1wire.c: In function 'OW_write_bit':
1-Wire App Note Source Code1wire.c:147: error: '_asm' undeclared (first use in this function)
1-Wire App Note Source Code1wire.c:147: error: syntax error before 'movlw'
1-Wire App Note Source Code1wire.c:149: error: syntax error before 'movlw'
1-Wire App Note Source Code1wire.c:155: error: syntax error before 'movlw'
1-Wire App Note Source Code1wire.c:157: error: syntax error before 'movlw'
1-Wire App Note Source Code1wire.c: In function 'OW_read_bit':
1-Wire App Note Source Code1wire.c:176: error: '_asm' undeclared (first use in this function)
1-Wire App Note Source Code1wire.c:176: error: syntax error before 'movlw'
1-Wire App Note Source Code1wire.c:178: error: syntax error before 'movlw'
1-Wire App Note Source Code1wire.c:182: error: syntax error before 'movlw'
1-Wire App Note Source Code1wire.c:230:95: warning: no newline at end of file

回帖(10)

王焕树

2019-5-27 13:23:22
AppNote是针对PIC18F设备的,使用C18编译器。您针对的是PIC24设备,并且使用C30编译器,所以汇编语言不可能兼容。只有汇编语言中需要精确的延时例程,其余的都在C中。另一个熟悉C30下的程序集的人需要重新创建它们。您使用C30而不是XC16有什么特别的原因吗?

以上来自于百度翻译


      以下为原文

    That AppNote is targeted at PIC18F devices, using the C18 compiler.
You are targeting a PIC24 device, and using the C30 compiler, so there's no way the assembly language will be compatible.
It's only the precise time delay routines that need to be in assembler, the rest is in C.
So either you, or someone else familiar with assembly under C30, needs to recreate them.
 
Is there any particular reason you are using C30 rather than XC16?
 
举报

李军林

2019-5-27 13:29:54
我担心,在任何时候花费在MPLLABX上,我可能会在升主动脉上吹一个洞,还有一些事情我想做。我无法处理X。我试着回到IDE 8.92。我假设XC16只与X一起工作。我涉猎的汇编比我承认的要多一点点,所以我可能弄清楚那些东西。我不认为指令集会有所不同,所以不会有移植问题。显然我错了。谢谢你的领导。

以上来自于百度翻译


      以下为原文

    I'm worried that, at any moment spent on MPLAB X, I may blow a hole in my ascending aorta and there's still a few things I'd like to do. I just can't deal with X. I tried and went back to IDE 8.92. I'm assuming XC16 only works with X. I have dabbled a little tiny bit more with assembly than I'm admitting to, so I could probably figure that stuff out. I didn't think the instruction set would be different , so there wouldn't be porting problems. Apparently I am mistaken. Thanks for the lead.
举报

王焕树

2019-5-27 13:44:27
值得一试。我在MPLAB8.92中使用XC8。XC8的最新版本忽略了将一些文件安装到MPLAB8中,但是较老的版本可以正确地安装到MPLAB8中,此后它与最新的版本一起工作。我假设XC16是类似的。与PIC18完全不同,从8位到16位处理器

以上来自于百度翻译


      以下为原文

   
It's worth a try.
I use XC8 with MPLAB8.92.
The most recent verisons of XC8 neglect to install some files into MPLAB8, but older versions do it correctly, and it works with the latest versions after that.
I'd assume XC16 is similar.
 
(I've never used a PIC24, but I would assume the assembly language is quite different to a PIC18, going from 8 bit to a 16 bit processor)
 
举报

李军林

2019-5-27 14:02:32
是的,我手头有PIC18和PIC24指令集(实际上上面写着“dsPIC30F/33F程序员的参考手册”),但它是我在论坛搜索24个指令集时出现的,所以我猜是一样的),而且你是对的……非常不同。是一个很好的改写ASM的项目。我不想通过说“不应该太难”来诅咒它。我会把旧的大学尝试给它。

以上来自于百度翻译


      以下为原文

    Yes I have in hand, instruction sets for PIC18 and PIC24 (Actually says "dsPIC30F/33F Programmer’s Reference Manual" but it's what came up in my Forum search for 24 instruction set, so I guess the same) and you are correct.....very different. Be a nice project rewriting the asm stuff. I don't want to hex a curse on it by saying "it shouldn't be too hard". I'll give it the old College try.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分