首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用MPLABx和XC8割让

用MPLABx和XC8割让
EN

Stack Overflow用户
提问于 2022-07-05 20:53:14
回答 1查看 123关注 0票数 0

我正在使用中的ceedling开始单元测试。在使用XC8编译器时,我已经取得了很大的进展。但我有一个似乎解决不了的问题。这里有一些构建转储。

代码语言:javascript
复制
'xc8-cc -mcpu=PIC16F18325 -gdwarf-3 -D"__PIC16f18325__" -D"__XC8" -D"UNITY_INT_WIDTH=16" -D"UNITY_POINTER_WIDTH=16" -D"CMOCK_MEM_INDEX_TYPE=uint16_t" -D"CMOCK_MEM_PTR_AS_INT=uint16_t" -D"CMOCK_MEM_ALIGN=1" -D"CMOCK_MEM_SIZE=256" -D"UNITY_OUTPUT_COLOR" -D"TEST" -D"UNITY_INCLUDE_CONFIG_H" -D"UNITY_EXCLUDE_SETJMP_H" -D"UNITY_EXCLUDE_MATH_H" -D"UNITY_EXCLUDE_FLOAT" -D"CMOCK_MEM_SIZE=256" -I"C:/Users/timtru/MPLABXProjects/XT_Lock_PIC16F18325.X/vendor/ceedling/vendor/unity/src" -I"C:/Users/timtru/MPLABXProjects/XT_Lock_PIC16F18325.X/vendor/ceedling/vendor/cmock/src" -I"build/ceedling/generated/test/mocks" -I"test" -I"test/source" -I"test/support" -I"source" -I"source/mcc_generated_files" -I"source/mcc_generated_files/docs/doxygen_generator" -I"source/mcc_generated_files/drivers" -I"C:/Program Files/Microchip/xc8/v2.36/pic/include" -I"C:/Program Files/Microchip/xc8/v2.36/pic/include/c90" -I"C:/Program Files/Microchip/xc8/v2.36/pic/include/c99" -I"C:/Program Files/Microchip/xc8/v2.36/pic/include/legacy" -I"C:/Program Files/Microchip/xc8/v2.36/pic/include/proc" -Wl,-Map="build/ceedling/generated/test/out/test_main.map" -o"./build/ceedling/generated/test/out/test_build.elf" build/ceedling/generated/test/out/c/test_main_runner.p1 build/ceedling/generated/test/out/c/test_main.p1 build/ceedling/generated/test/out/c/unity.p1 build/ceedling/generated/test/out/c/mcc.p1 build/ceedling/generated/test/out/c/main.p1 build/ceedling/generated/test/out/c/I2_p0.p1 build/ceedling/generated/test/out/c/process_commands.p1 build/ceedling/generated/test/out/c/cmock.p1 2>&1'
> Produced output:
C:\Program Files\Microchip\xc8\v2.36\pic\sources\c99\pic\__eeprom.c:22:9: error: use of undeclared identifier 'NVMCON1bits'

'NVMCON1bits在XC8安装目录下的pic16f18325.h文件中声明--“C:/Program/Microchip/xc8 8/v2.36/pic/ -I /proc”,它被视为xc8-cc参数列表中的最后一个-I。在IDE MPLAB中,使用XC.H文件通知编译器它正在构建的处理器。这种机制导致正确的“处理器”.h文件被拉入。必须出现在每个源文件中。需要什么(在project.yml中)才能使它工作?

代码语言:javascript
复制
# Notes:
# Project.yml


:project:
  :build_root: build/ceedling/generated
  :test_file_prefix: test_
  :which_ceedling: vendor/ceedling
  :use_exceptions: FALSE
  :release_build: FALSE
  :use_test_preprocessor: FALSE
  :use_auxiliary_dependencies: TRUE
  :default_tasks:
    - test:all

:environment:
  - :mcu: PIC16F18325
  - :mplabx_root: "C:/Program Files/Microchip/xc8/v2.36/"
  - :path:
    - "C:/Program Files/Microchip/xc8/v2.36/pic/include/**"
    - "#{ENV['PATH']}"
    - build
    - source/**
    - source/*
    - vendor/ceedling/vendor/unity/src


#:test_build:
#  :use_assembly: TRUE

#:release_build:
#  :output: MyApp.out
#  :use_assembly: FALSE



:module_generator:
  :project_root: ./
  :source_root: source/
  :test_root: test/
  
:extension:
  :object: .p1
  :executable: .elf
  :assembly: .S

:paths:
  :test:
    - +:test/**
    - -:test/support
  :source:
    - source/**
    - -:source/mcc_generated_files/docs
    - -:source/mcc_generated_files/examples
  :include:
    - "C:/Program Files/Microchip/xc8/v2.36/pic/include/*"
    - "C:/Program Files/Microchip/xc8/v2.36/pic/include/proc/pic16f18325.h"
  :support:
    - test/support
  :libraries: []

:defines:
  # in order to add common defines:
  #  1) remove the trailing [] from the :common: section
  #  2) add entries to the :common: section (e.g. :test: has TEST defined)
  :commmon: &common_defines
    - __PIC16f18325__
    - __XC8
    - UNITY_INT_WIDTH=16
    - UNITY_POINTER_WIDTH=16
    - CMOCK_MEM_INDEX_TYPE=uint16_t
    - CMOCK_MEM_PTR_AS_INT=uint16_t
    - CMOCK_MEM_ALIGN=1
    - CMOCK_MEM_SIZE=256
  :test:
    - *common_defines
#    - UNITY_INCLUDE_CONFIG_H
    - UNITY_OUTPUT_COLOR #this is just here to make sure it gets removed by ceedling
    - TEST
  :test_preprocess:
    - *common_defines
    - TEST
:unity:
  :defines:
    - UNITY_INCLUDE_CONFIG_H 
    - UNITY_EXCLUDE_SETJMP_H
    - UNITY_EXCLUDE_MATH_H
    - UNITY_EXCLUDE_FLOAT
    
:cmock:
  :mock_prefix: mock_
  :when_no_prototypes: :warn
  :treat_externs: :include
  :enforce_strict_ordering: TRUE
  :fail_on_unexpected_calls: FALSE
  :exclude_setjmp_h: TRUE
  :defines:
    - CMOCK_MEM_SIZE=256
  :plugins:
    - :ignore
    - :ignore_arg
    - :callback
    - :expect_any_args
  :treat_as:
    int8:       INT8
    uint8:      HEX8
    uint16:     HEX16
    uint32:     UINT32
    int8_t:     INT8
    uint8_t:    HEX8
    uint16_t:   HEX16
    uint32_t:   UINT32
    bool:       UINT8

# Add -gcov to the plugins list to make sure of the gcov plugin
# You will need to have gcov and gcovr both installed to make it work.
# For more information on these options, see docs in plugins/gcov
:gcov:
  :reports:
    - HtmlDetailed
  :gcovr:
    :html_medium_threshold: 75
    :html_high_threshold: 90

:tools:
  :release_compiler:
    :name: "Microchip XC8 Compiler"
    :executable: xc8-cc
    :arguments:
      - "-mcpu=#{ENV['MCU']}"
      - -std=c99
      - -O1
      - -Wa,-a
      - -D"$": COLLECTION_DEFINES_RELEASE_AND_VENDOR
      - -I"$": COLLECTION_PATHS_SOURCE_AND_INCLUDE
      - -Iinclude/
      - -o "${2}"
      - -c
      - "${1}"

  :release_assembler:
    :name: "Microchip XC8 Compiler"
    :executable: xc8-cc
    :arguments:
      - "-mcpu=#{ENV['MCU']}"
      - -std=c99
      - -O1
      - -Wa,-a
      - -D"$": COLLECTION_DEFINES_RELEASE_AND_VENDOR
      - -I"$": COLLECTION_PATHS_SOURCE_AND_INCLUDE
      - -o "${2}"
      - -c
      - "${1}"

  :release_linker:
    :name: "Microchip XC8 Linker"
    :executable: xc8-cc
    :arguments:
      - "-mcpu=#{ENV['MCU']}"
      - -gdwarf-3
      - -D"$": COLLECTION_DEFINES_RELEASE_AND_VENDOR
      - -I"$": COLLECTION_PATHS_SOURCE_AND_INCLUDE
      - -Wl,-Map="${3}"
      - -o "${2}"
      - "{'${1}'.split(' ').map { |x| (x.include? '/out/c/') ? (Pathname(x).sub_ext('.p1')).to_s : x }.join(' ') }"
      - "${4}"

  :test_compiler:
    :name: "Microchip XC8 Compiler"
    :executable: xc8-cc
    :arguments:
      - -mcpu=#{ENV['MCU']}
      - -std=c99
      - -O1
      - -Wa,-a
      - -D"$": COLLECTION_DEFINES_TEST_AND_VENDOR
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
      - -Iinclude/
      - -o "${2}"
      - -c
      - "${1}"

  :test_file_preprocessor:
    :name: "Microchip XC8 preprocessor"
    :executable: xc8-cc
    :arguments:
      - -mcpu=#{ENV['MCU']}
      - -std=c99
      - -D"$": COLLECTION_DEFINES_TEST_AND_VENDOR
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
      - "${1}"

  :test_includes_preprocessor:
    :name: "Microchip XC8 includes preprocessor"
    :executable: xc8-cc
    :arguments:
      - -mcpu=#{ENV['MCU']}
      - -std=c99
      - -D"$": COLLECTION_DEFINES_TEST_AND_VENDOR
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
      - "${1}"

  :test_linker:
    :name: "Microchip XC8 Linker"
    :executable: xc8-cc
    :arguments:
      - -mcpu=#{ENV['MCU']}
      - -gdwarf-3
      - -D"$": COLLECTION_DEFINES_TEST_AND_VENDOR
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
      - -Wl,-Map="${3}"
      - -o"./build/ceedling/generated/test/out/test_build.elf"
      - "{'${1}'.split(' ').map { |x| (x.include? '/out/c/') ? (Pathname(x).sub_ext('.p1')).to_s : x }.join(' ') }"
      - "${4}"

  :test_fixture:
    :executable: ruby
    :name: "Microchip simulator test fixture"
    :stderr_redirect: :win #inform Ceedling what model of $stderr capture to use
    :arguments:
      - test/simulation/sim_test_fixture.rb

:plugins:
  :load_paths:
    - vendor/ceedling/plugins
  :enabled:
    - stdout_pretty_tests_report
    - module_generator
    - raw_output_report
    - warnings_report
EN

回答 1

Stack Overflow用户

发布于 2022-07-11 13:12:02

您可能会在这个博客上找到有用的信息(Ceedling维护者):单元测试怎么做?寄存器

您在test/support中有任何文件吗?

有一种方法来测试您的PIC寄存器,但这需要一些努力,以修改您的原始PIC头文件。

让我介绍一下我在dsPIC33和XC16中所做的事情,这对于XC8来说应该是非常相似的。

我使用的是从XC16目录复制到support的修改后的support,其中:

  • 在顶部添加了此代码,因为我使用XC16或GCC编译器进行编译:
代码语言:javascript
复制
#ifdef TEST_GCC
#define EXTERN 
#else
#define EXTERN extern
#endif
  • 删除每一个__attribute__((..。
  • 将每个extern替换为EXTERN
  • 添加了以下代码:
代码语言:javascript
复制
/* ---------------------------------------------------------- */
/* Some useful macros for inline assembler instructions       */
/* ---------------------------------------------------------- */
    
#define Nop()    ; //__builtin_nop()
#define ClrWdt() ; //__builtin_clrwdt()
#define Sleep()  ; //__builtin_pwrsav(0)
#define Idle()   ; //__builtin_pwrsav(1)

您还可能必须向include添加支持目录:

代码语言:javascript
复制
:paths:
  :test:
    - +:test/**
    - -:test/support
  :source:
    - src/**
  :support:
    - test/support  
  :include:
    - test/support 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72875396

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档