Errors when trying to add DMAC ASF module to a C++ project with SAMD21 device

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey guys, I'm trying to add the "DMAC - Direct Memory Access Controller" module through ASF to my C++ project, but I'm getting errors right after adding the module.

 

I know I get this disclaimer that says C++ projects are not really guaranteed:

 

Atmel Studio's disclaimer that ASF modules are not guaranteed in C++.

 

But still, I don't understand why it should not be possible. In the past I added the modules; ADC, WDT, GPIO, I2S, USART, TC, TCC, Generic board support and Delay routines all with success.

 

That said, let me get to the problem. To make sure nothing else was conflicting in the project, I tried creating a blank C++ project, selected my device (ATSAMD21G16B), selected a blank user board, and coded nothing yet. This empty project builds as expected. Then as a first step I tried adding the DMAC module through ASF. After a first build I instantly get these errors:

 

Atmel errors

 

This is the output window:

 

------ Build started: Project: MyProject, Configuration: Debug ------
Build started.
Project "MyProject.cppproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "C:\Users\Me\Documents\MySolution\MyProject\MyProject.cppproj" (target "Build" depends on it):
	Task "RunCompilerTask"
		Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
		C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe all --jobs 4 --output-sync
		Building file: ../src/ASF/common2/boards/user_board/init.c
		Invoking: ARM/GNU C Compiler : 6.3.1
		In file included from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include/cmsis_compiler.h:48:0,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include/core_cm0plus.h:113,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include/samd21g16b.h:234,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include/samd21.h:55,
		                 from ../src/ASF/sam0/utils/header_files/io.h:62,
		                 from ../src/ASF/sam0/utils/compiler.h:65,
		                 from ../src/asf.h:56,
		                 from ../src/ASF/common2/boards/user_board/init.c:11:
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(1350,6): warning: "__ARM_FEATURE_DSP" is not defined [-Wundef]
		 #if (__ARM_FEATURE_DSP == 1)                             /* ToDo ARMCLANG: This should be ARCH >= ARMv7-M + SIMD */
		      ^~~~~~~~~~~~~~~~~
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe"  -x c -mthumb -D__SAMD21G16B__ -DDEBUG -DBOARD=USER_BOARD -DARM_MATH_CM0PLUS=true  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include" -I"../src/ASF/common/boards" -I"../src/ASF/sam0/utils" -I"../src/ASF/sam0/utils/header_files" -I"../src/ASF/sam0/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/common/utils" -I"../src/ASF/sam0/utils/cmsis/samd21/include" -I"../src/ASF/sam0/utils/cmsis/samd21/source" -I"../src/ASF/sam0/drivers/system" -I"../src/ASF/sam0/drivers/system/clock/clock_samd21_r21_da_ha1" -I"../src/ASF/sam0/drivers/system/clock" -I"../src/ASF/sam0/drivers/system/interrupt" -I"../src/ASF/sam0/drivers/system/interrupt/system_interrupt_samd21" -I"../src/ASF/sam0/drivers/system/pinmux" -I"../src/ASF/sam0/drivers/system/power" -I"../src/ASF/sam0/drivers/system/power/power_sam_d_r_h" -I"../src/ASF/sam0/drivers/system/reset" -I"../src/ASF/sam0/drivers/system/reset/reset_sam_d_r_h" -I"../src/ASF/common2/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam0/drivers/dma"  -O1 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m0plus -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return  -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -MD -MP -MF "src/ASF/common2/boards/user_board/init.d" -MT"src/ASF/common2/boards/user_board/init.d" -MT"src/ASF/common2/boards/user_board/init.o"   -o "src/ASF/common2/boards/user_board/init.o" "../src/ASF/common2/boards/user_board/init.c"
C:\Users\Me\Documents\MySolution\MyProject\Debug\Makefile(228,1): error: recipe for target 'src/ASF/common2/boards/user_board/init.o' failed
		In file included from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include/cmsis_compiler.h:48:0,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include/core_cm0plus.h:113,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include/samd21g16b.h:234,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include/samd21.h:55,
		                 from ../src/ASF/sam0/utils/header_files/io.h:62,
		                 from ../src/ASF/sam0/utils/compiler.h:65,
		                 from ../src/asf.h:56,
		                 from ../src/ASF/common2/boards/user_board/init.c:11:
		../src/ASF/sam0/drivers/dma/dma_crc.h: In function 'dma_crc_io_calculation':
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(36,37): error: expected expression before '__asm'
		   #define __ASM                     __asm
		                                     ^
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(698,45): info: in expansion of macro '__ASM'
		 #define __NOP()                             __ASM volatile ("nop")       /* This implementation generates debug information */
		                                             ^~~~~
C:\Users\Me\Documents\MySolution\MyProject\src\ASF\sam0\utils\compiler.h(1036,30): info: in expansion of macro '__NOP'
		 #define nop()               (__NOP())
		                              ^~~~~
C:\Users\Me\Documents\MySolution\MyProject\src\ASF\sam0\drivers\dma\dma_crc.h(219,3): info: in expansion of macro 'nop'
		   nop();
		   ^~~
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(36,37): error: expected expression before '__asm'
		   #define __ASM                     __asm
		                                     ^
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(698,45): info: in expansion of macro '__ASM'
		 #define __NOP()                             __ASM volatile ("nop")       /* This implementation generates debug information */
		                                             ^~~~~
C:\Users\Me\Documents\MySolution\MyProject\src\ASF\sam0\utils\compiler.h(1036,30): info: in expansion of macro '__NOP'
		 #define nop()               (__NOP())
		                              ^~~~~
C:\Users\Me\Documents\MySolution\MyProject\src\ASF\sam0\drivers\dma\dma_crc.h(220,3): info: in expansion of macro 'nop'
		   nop();
		   ^~~
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(36,37): error: expected expression before '__asm'
		   #define __ASM                     __asm
		                                     ^
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(698,45): info: in expansion of macro '__ASM'
		 #define __NOP()                             __ASM volatile ("nop")       /* This implementation generates debug information */
		                                             ^~~~~
C:\Users\Me\Documents\MySolution\MyProject\src\ASF\sam0\utils\compiler.h(1036,30): info: in expansion of macro '__NOP'
		 #define nop()               (__NOP())
		                              ^~~~~
C:\Users\Me\Documents\MySolution\MyProject\src\ASF\sam0\drivers\dma\dma_crc.h(221,3): info: in expansion of macro 'nop'
		   nop();
		   ^~~
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(36,37): error: expected expression before '__asm'
		   #define __ASM                     __asm
		                                     ^
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(698,45): info: in expansion of macro '__ASM'
		 #define __NOP()                             __ASM volatile ("nop")       /* This implementation generates debug information */
		                                             ^~~~~
C:\Users\Me\Documents\MySolution\MyProject\src\ASF\sam0\utils\compiler.h(1036,30): info: in expansion of macro '__NOP'
		 #define nop()               (__NOP())
		                              ^~~~~
C:\Users\Me\Documents\MySolution\MyProject\src\ASF\sam0\drivers\dma\dma_crc.h(222,3): info: in expansion of macro 'nop'
		   nop();
		   ^~~
		make: *** [src/ASF/common2/boards/user_board/init.o] Error 1
		make: *** Waiting for unfinished jobs....
		Building file: ../src/ASF/common/utils/interrupt/interrupt_sam_nvic.c
		Invoking: ARM/GNU C Compiler : 6.3.1
		In file included from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include/cmsis_compiler.h:48:0,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include/core_cm0plus.h:113,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include/samd21g16b.h:234,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include/samd21.h:55,
		                 from ../src/ASF/sam0/utils/header_files/io.h:62,
		                 from ../src/ASF/sam0/utils/compiler.h:65,
		                 from ../src/ASF/common/utils/interrupt/interrupt_sam_nvic.h:50,
		                 from ../src/ASF/common/utils/interrupt/interrupt_sam_nvic.c:47:
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(1350,6): warning: "__ARM_FEATURE_DSP" is not defined [-Wundef]
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe"  -x c -mthumb -D__SAMD21G16B__ -DDEBUG -DBOARD=USER_BOARD -DARM_MATH_CM0PLUS=true  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include" -I"../src/ASF/common/boards" -I"../src/ASF/sam0/utils" -I"../src/ASF/sam0/utils/header_files" -I"../src/ASF/sam0/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/common/utils" -I"../src/ASF/sam0/utils/cmsis/samd21/include" -I"../src/ASF/sam0/utils/cmsis/samd21/source" -I"../src/ASF/sam0/drivers/system" -I"../src/ASF/sam0/drivers/system/clock/clock_samd21_r21_da_ha1" -I"../src/ASF/sam0/drivers/system/clock" -I"../src/ASF/sam0/drivers/system/interrupt" -I"../src/ASF/sam0/drivers/system/interrupt/system_interrupt_samd21" -I"../src/ASF/sam0/drivers/system/pinmux" -I"../src/ASF/sam0/drivers/system/power" -I"../src/ASF/sam0/drivers/system/power/power_sam_d_r_h" -I"../src/ASF/sam0/drivers/system/reset" -I"../src/ASF/sam0/drivers/system/reset/reset_sam_d_r_h" -I"../src/ASF/common2/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam0/drivers/dma"  -O1 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m0plus -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return  -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -MD -MP -MF "src/ASF/common/utils/interrupt/interrupt_sam_nvic.d" -MT"src/ASF/common/utils/interrupt/interrupt_sam_nvic.d" -MT"src/ASF/common/utils/interrupt/interrupt_sam_nvic.o"   -o "src/ASF/common/utils/interrupt/interrupt_sam_nvic.o" "../src/ASF/common/utils/interrupt/interrupt_sam_nvic.c"
		Finished building: ../src/ASF/common/utils/interrupt/interrupt_sam_nvic.c
		 #if (__ARM_FEATURE_DSP == 1)                             /* ToDo ARMCLANG: This should be ARCH >= ARMv7-M + SIMD */
		      ^~~~~~~~~~~~~~~~~
		Building file: .././main.cpp
		Invoking: ARM/GNU C Compiler : 6.3.1
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-g++.exe" -mthumb -D__SAMD21G16B__ -DDEBUG -DBOARD=USER_BOARD -DARM_MATH_CM0PLUS=true  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include" -I"../src/ASF/common/boards" -I"../src/ASF/sam0/utils" -I"../src/ASF/sam0/utils/header_files" -I"../src/ASF/sam0/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/common/utils" -I"../src/ASF/sam0/utils/cmsis/samd21/include" -I"../src/ASF/sam0/utils/cmsis/samd21/source" -I"../src/ASF/sam0/drivers/system" -I"../src/ASF/sam0/drivers/system/clock/clock_samd21_r21_da_ha1" -I"../src/ASF/sam0/drivers/system/clock" -I"../src/ASF/sam0/drivers/system/interrupt" -I"../src/ASF/sam0/drivers/system/interrupt/system_interrupt_samd21" -I"../src/ASF/sam0/drivers/system/pinmux" -I"../src/ASF/sam0/drivers/system/power" -I"../src/ASF/sam0/drivers/system/power/power_sam_d_r_h" -I"../src/ASF/sam0/drivers/system/reset" -I"../src/ASF/sam0/drivers/system/reset/reset_sam_d_r_h" -I"../src/ASF/common2/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam0/drivers/dma"  -O1 -ffunction-sections -fno-rtti -fno-exceptions -mlong-calls -g3 -Wall -mcpu=cortex-m0plus -c -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.cpp"
		Finished building: .././main.cpp
		Building file: ../src/ASF/sam0/drivers/dma/dma.c
		Invoking: ARM/GNU C Compiler : 6.3.1
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe"  -x c -mthumb -D__SAMD21G16B__ -DDEBUG -DBOARD=USER_BOARD -DARM_MATH_CM0PLUS=true  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include" -I"../src/ASF/common/boards" -I"../src/ASF/sam0/utils" -I"../src/ASF/sam0/utils/header_files" -I"../src/ASF/sam0/utils/preprocessor" -I"../src/ASF/thirdparty/CMSIS/Include" -I"../src/ASF/thirdparty/CMSIS/Lib/GCC" -I"../src/ASF/common/utils" -I"../src/ASF/sam0/utils/cmsis/samd21/include" -I"../src/ASF/sam0/utils/cmsis/samd21/source" -I"../src/ASF/sam0/drivers/system" -I"../src/ASF/sam0/drivers/system/clock/clock_samd21_r21_da_ha1" -I"../src/ASF/sam0/drivers/system/clock" -I"../src/ASF/sam0/drivers/system/interrupt" -I"../src/ASF/sam0/drivers/system/interrupt/system_interrupt_samd21" -I"../src/ASF/sam0/drivers/system/pinmux" -I"../src/ASF/sam0/drivers/system/power" -I"../src/ASF/sam0/drivers/system/power/power_sam_d_r_h" -I"../src/ASF/sam0/drivers/system/reset" -I"../src/ASF/sam0/drivers/system/reset/reset_sam_d_r_h" -I"../src/ASF/common2/boards/user_board" -I"../src" -I"../src/config" -I"../src/ASF/sam0/drivers/dma"  -O1 -fdata-sections -ffunction-sections -mlong-calls -g3 -Wall -mcpu=cortex-m0plus -c -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return  -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -MD -MP -MF "src/ASF/sam0/drivers/dma/dma.d" -MT"src/ASF/sam0/drivers/dma/dma.d" -MT"src/ASF/sam0/drivers/dma/dma.o"   -o "src/ASF/sam0/drivers/dma/dma.o" "../src/ASF/sam0/drivers/dma/dma.c"
		Finished building: ../src/ASF/sam0/drivers/dma/dma.c
		In file included from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include/cmsis_compiler.h:48:0,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include/core_cm0plus.h:113,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include/samd21g16b.h:234,
		                 from C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\SAMD21_DFP\1.3.304\samd21c\include/samd21.h:55,
		                 from ../src/ASF/sam0/utils/header_files/io.h:62,
		                 from ../src/ASF/sam0/utils/compiler.h:65,
		                 from ../src/ASF/sam0/drivers/dma/dma.h:321,
		                 from ../src/ASF/sam0/drivers/dma/dma.c:48:
C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h(1350,6): warning: "__ARM_FEATURE_DSP" is not defined [-Wundef]
		 #if (__ARM_FEATURE_DSP == 1)                             /* ToDo ARMCLANG: This should be ARCH >= ARMv7-M + SIMD */
		      ^~~~~~~~~~~~~~~~~
	Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "MyProject.cppproj" -- FAILED.
Done building project "MyProject.cppproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

 

I used the DMAC module before in a different project. This project was based on the "Quick Start for the SAM I2S Driver (DMA)" example project which is made to run on a SAM D21 Xplained Pro Evaluation Kit (which uses the ATSAMD21J18A, a slightly different device than my user board with a ATSAMD21G16B). After working with this example project on the evaluation kit successfully, I wanted to port the code I created with the ASF module to my C++ project on the actual board/device. This is where it went wrong...

 

The difference I can mention between the projects:

  • The example project is a C project while my project is a C++ project.
  • The example project uses no "Packs" while my project uses CMSIS and the SAMD21_DFP "Packs". These Packs are found somewhere under "C:\Program Files (x86)\Atmel\Studio\..." This is interesting because when I look at the working example project that uses the DMAC module, I find that this same(?) CMSIS stuff is added to the project in "[MY_ATMEL_PROJECT_ROOT]\src\ASF\thirdparty\CMSIS".

 

Below is the part where it fails, it is somewhere at the and of the file dma_crc.h (a file from the DMAC ASF module), it uses nop():
 

[MY_ATMEL_PROJECT_ROOT]\src\ASF\sam0\drivers\dma\dma_crc.h

static inline void dma_crc_io_calculation(void *buffer,
         uint32_t total_beat_size)
{
    uint32_t counter = total_beat_size;
    uint8_t *buffer_8;
    uint16_t *buffer_16;
    uint32_t *buffer_32;

    for (counter=0; counter<total_beat_size; counter++) {
        if (DMAC->CRCCTRL.bit.CRCBEATSIZE == CRC_BEAT_SIZE_BYTE) {
            buffer_8 = buffer;
            DMAC->CRCDATAIN.reg = buffer_8[counter];
        } else if (DMAC->CRCCTRL.bit.CRCBEATSIZE == CRC_BEAT_SIZE_HWORD) {
            buffer_16 = buffer;
            DMAC->CRCDATAIN.reg = buffer_16[counter];
        } else if (DMAC->CRCCTRL.bit.CRCBEATSIZE == CRC_BEAT_SIZE_WORD) {
            buffer_32 = buffer;
            DMAC->CRCDATAIN.reg = buffer_32[counter];
        }
        /* Wait several cycle to make sure CRC complete */
        nop();
        nop();
        nop();
        nop();
    }
}

 

When I look into nop(), it goes to compiler.h:

 

[MY_ATMEL_PROJECT_ROOT]\src\ASF\sam0\utils\compiler.h

/* No operation */
#if defined(__ICCARM__)
#define nop()               __no_operation()
#elif defined(__GNUC__)
#define nop()               (__NOP())
#endif

 

Then to follow __NOP(), it goes to either core_cmInstr.h (thirdparty\CMSIS) or cmsis_gcc.h from the "Pack":

 

[MY_ATMEL_PROJECT_ROOT]\src\ASF\thirdparty\CMSIS\Include\core_cmInstr.h

#define __NOP                             __nop

 

... and later in the file:

 

__attribute__( ( always_inline ) ) __STATIC_INLINE void __NOP(void)
{
  __ASM volatile ("nop");
}

 

C:\Program Files (x86)\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include\cmsis_gcc.h

#define __NOP()                             __ASM volatile ("nop")

 

As far as I understand it looks like there are multiple definitions of the nop() function through different files. The thing is, when I try to follow the same nop() from the example project that uses the DMAC module (so I start with dma_crc.h also), it does not get to cmsis_gcc.h, but only to the core_cmInstr.h (from the thirdparty\CMSIS), and not from the "Pack" because it is not installed. Could this be the reason?

 

What's going wrong? How could I let the DMAC module work in my C++ project?

This topic has a solution.

Maybe someday I'll have a nice quote here.

Last Edited: Wed. Feb 13, 2019 - 08:41 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fixed the errors by editing the source code of the ASF driver:

static inline void dma_crc_io_calculation(void *buffer,
         uint32_t total_beat_size)
{
    uint32_t counter = total_beat_size;
    uint8_t *buffer_8;
    uint16_t *buffer_16;
    uint32_t *buffer_32;

    for (counter=0; counter<total_beat_size; counter++) {
        if (DMAC->CRCCTRL.bit.CRCBEATSIZE == CRC_BEAT_SIZE_BYTE) {
            buffer_8 = (uint8_t*)buffer;
            DMAC->CRCDATAIN.reg = buffer_8[counter];
        } else if (DMAC->CRCCTRL.bit.CRCBEATSIZE == CRC_BEAT_SIZE_HWORD) {
            buffer_16 = (uint16_t*)buffer;
            DMAC->CRCDATAIN.reg = buffer_16[counter];
        } else if (DMAC->CRCCTRL.bit.CRCBEATSIZE == CRC_BEAT_SIZE_WORD) {
            buffer_32 = (uint32_t*)buffer;
            DMAC->CRCDATAIN.reg = buffer_32[counter];
        }
        /* Wait several cycle to make sure CRC complete */
        asm volatile ("nop"::);
        asm volatile ("nop"::);
        asm volatile ("nop"::);
        asm volatile ("nop"::);
    }
}

At first I didn't want to touch the code and thought it could be fixed another way, but heck, this works too...

Maybe someday I'll have a nice quote here.