OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2659|回复: 1

keil 工程移植到IAR问题

[复制链接]

4

主题

7

帖子

0

精华

初级会员

Rank: 2

积分
88
金钱
88
注册时间
2017-1-17
在线时间
11 小时
发表于 2018-4-10 20:41:47 | 显示全部楼层 |阅读模式
用原子哥战舰光盘里面的KEIL工程移植到IAR出现如图问题,怎么解决?

编译提示如下

Building configuration: test - Debug
Updating build tree...
sys.c  
Error[Pe040]: expected an identifier C:\Users\Administrator\Desktop\test\SYSTEM\sys\sys.c 33
Error[Pe020]: identifier "MSR" is undefined C:\Users\Administrator\Desktop\test\SYSTEM\sys\sys.c 35
Error[Pe065]: expected a ";" C:\Users\Administrator\Desktop\test\SYSTEM\sys\sys.c 36
Error while running C/C++ Compiler

Total number of errors: 3
Total number of warnings: 0


编译错误提示

编译错误提示
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

0

主题

30

帖子

0

精华

初级会员

Rank: 2

积分
115
金钱
115
注册时间
2018-4-4
在线时间
17 小时
发表于 2018-4-11 08:17:15 | 显示全部楼层
本帖最后由 queelys 于 2018-4-11 08:28 编辑

IAR不支持__asm void这样的汇编函数。
你要新建一个.s的汇编文件,把汇编函数和代码放在里面,参考一下FreeRTOS的写法吧,如下:


/*
    FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.
    All rights reserved

    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.

    This file is part of the FreeRTOS distribution.

    FreeRTOS is free software; you can redistribute it and/or modify it under
    the terms of the GNU General Public License (version 2) as published by the
    Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.

    ***************************************************************************
    >>!   NOTE: The modification to the GPL is included to allow you to     !<<
    >>!   distribute a combined work that includes FreeRTOS without being   !<<
    >>!   obliged to provide the source code for proprietary components     !<<
    >>!   outside of the FreeRTOS kernel.                                   !<<
    ***************************************************************************

    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  Full license text is available on the following
    link: http://www.freertos.org/a00114.html

    ***************************************************************************
     *                                                                       *
     *    FreeRTOS provides completely free yet professionally developed,    *
     *    robust, strictly quality controlled, supported, and cross          *
     *    platform software that is more than just the market leader, it     *
     *    is the industry's de facto standard.                               *
     *                                                                       *
     *    Help yourself get started quickly while simultaneously helping     *
     *    to support the FreeRTOS project by purchasing a FreeRTOS           *
     *    tutorial book, reference manual, or both:                          *
     *    http://www.FreeRTOS.org/Documentation                              *
     *                                                                       *
    ***************************************************************************

    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading
    the FAQ page "My application does not run, what could be wrong?".  Have you
    defined configASSERT()?

    http://www.FreeRTOS.org/support - In return for receiving this top quality
    embedded software for free we request you assist our global community by
    participating in the support forum.

    http://www.FreeRTOS.org/training - Investing in training allows your team to
    be as productive as possible as early as possible.  Now you can receive
    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
    Ltd, and the world's leading authority on the world's leading RTOS.

    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
    including FreeRTOS+Trace - an indispensable productivity tool, a DOS
    compatible FAT file system, and our tiny thread aware UDP/IP stack.

    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.

    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS
    licenses offer ticketed support, indemnification and commercial middleware.

    http://www.SafeRTOS.com - High Integrity Systems also provide a safety
    engineered and independently SIL3 certified version for use in safety and
    mission critical applications that require provable dependability.

    1 tab == 4 spaces!
*/

#include "/include/FreeRTOSConfig.h"

        RSEG    CODE:CODE(2)
        thumb

        EXTERN pxCurrentTCB
        EXTERN vTaskSwitchContext

        PUBLIC xPortPendSVHandler
        PUBLIC ulPortSetInterruptMask
        PUBLIC vPortClearInterruptMask
        PUBLIC vPortSVCHandler
        PUBLIC vPortStartFirstTask



/*-----------------------------------------------------------*/

xPortPendSVHandler:
        mrs r0, psp
        isb
        ldr        r3, =pxCurrentTCB                        /* Get the location of the current TCB. */
        ldr        r2, [r3]

        stmdb r0!, {r4-r11}                                /* Save the remaining registers. */
        str r0, [r2]                                        /* Save the new top of stack into the first member of the TCB. */

        stmdb sp!, {r3, r14}
        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
        msr basepri, r0
        bl vTaskSwitchContext
        mov r0, #0
        msr basepri, r0
        ldmia sp!, {r3, r14}

        ldr r1, [r3]
        ldr r0, [r1]                                        /* The first item in pxCurrentTCB is the task top of stack. */
        ldmia r0!, {r4-r11}                                /* Pop the registers. */
        msr psp, r0
        isb
        bx r14


/*-----------------------------------------------------------*/

ulPortSetInterruptMask:
        mrs r0, basepri
        mov r1, #configMAX_SYSCALL_INTERRUPT_PRIORITY
        msr basepri, r1
        bx r14

/*-----------------------------------------------------------*/

vPortClearInterruptMask:
        msr basepri, r0
        bx r14

/*-----------------------------------------------------------*/

vPortSVCHandler:
        /* Get the location of the current TCB. */
        ldr        r3, =pxCurrentTCB
        ldr r1, [r3]
        ldr r0, [r1]
        /* Pop the core registers. */
        ldmia r0!, {r4-r11}
        msr psp, r0
        isb
        mov r0, #0
        msr        basepri, r0
        orr r14, r14, #13
        bx r14

/*-----------------------------------------------------------*/

vPortStartFirstTask
        /* Use the NVIC offset register to locate the stack. */
        ldr r0, =0xE000ED08
        ldr r0, [r0]
        ldr r0, [r0]
        /* Set the msp back to the start of the stack. */
        msr msp, r0
        /* Call SVC to start the first task, ensuring interrupts are enabled. */
        cpsie i
        cpsie f
        dsb
        isb
        svc 0

        END


回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-9 08:45

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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