3817 views|5 replies

4

Posts

0

Resources
The OP
 

I really need help with this strange linking error. It has been bothering me for days. [Copy link]

  I recently encountered a rather strange problem when I was studying the embedded development board nrf52832 and using the keil software for simulation. linking... .\Objects\Experiment.axf: Error: L6218E: Undefined symbol nrf_drv_pwm_init (referred from motor.o). .\Objects\Experiment.axf: Error: L6218E: Undefined symbol nrf_drv_pwm_simple_playback (referred from motor.o). Yes, the link error that we like to see. Usually, this problem can be solved by adding .c and .h files and then checking the project addition path, but this time it didn't work. I repeatedly confirmed whether the .C and even .H file paths of these two functions were added, whether the project included them, whether the variables were correct, and even changing the function names was useless. The Keil compiler still reported these two errors to me tirelessly. Finally, I simply wrote these two functions into the main function and no longer divided them into multiple .C files. As a result, I crashed. There were still these two errors, but they changed from motor.c to main.c. I would like to ask what is going on here, I feel like I have fallen into a vicious circle, please help me figure out what is going on. The motor.c code is as follows: [code]#include "nrf52.h" #include "nrf_gpio.h" #include "motor.h" #include "nrf_drv_pwm.h" #include "nrf_delay.h" #define TOP 5000 nrf_drv_pwm_t m_pwm0 = NRF_DRV_PWM_INSTANCE(0); nrf_pwm_values_individual_t seq0_values; nrf_pwm_sequence_t const seq0 = {
This post is from ARM Technology

Latest reply

https://devzone.nordicsemi.com/f ... eferred-from-main-o This website answers the question...The answer is in the last sentence. In simple terms, you need to add this code in config.h: #ifndef PWM_ENABLED #define PWM_ENABLED 1 #endif #ifndef PWM0_ENABLED #define PWM0_ENABLED 1 #endif #ifndef PWM1_ENABLED #define PWM1_ENABLED 1 #endif #ifndef PWM2_ENABLED #define PWM2_ENABLED 1 #endif You need to define PWM0_ENABLED in config. I am also working on this smart bracelet project recently. If you can, add my QQ 840693710 for communication.  Details Published on 2019-3-17 03:08
 

6366

Posts

4936

Resources
2
 
Functions are declared in .h and defined in .c.
This post is from ARM Technology
 
 
 

6040

Posts

204

Resources
3
 
This error is obvious: Undefined symbol nrf_drv_pwm_init (referred from motor.o). The symbol nrf_drv_pwm_init is referenced in motor.c, but not defined. Then you should find the place where this symbol is defined, either a c file or a library file, and add them to the project. The definition mentioned above refers to the implementation, not the declaration in the header file.
This post is from ARM Technology
 
 
 

4

Posts

0

Resources
4
 
lcofjp posted on 2019-1-18 12:18 This error is very obvious: Undefined symbol nrf_drv_pwm_init (referred from motor.o). nrf_drv_p ... referenced in motor.c
I just solved this problem. The reason is that it is not implemented, but the reason for not being implemented is that I wrote it between #if and #endif. I am confused. Is it possible that the code between #if and #endif in Keil is not compiled and implemented? I hope to answer it. Thank you very much
This post is from ARM Technology

Comments

The #if instruction is followed by a condition, and the program will not compile unless the condition is met. That condition is more complicated than the if statement in the program. Sometimes, if you accidentally write it wrong, it will cause it to not compile.  Details Published on 2019-1-18 17:08
 
 
 

6040

Posts

204

Resources
5
 
Oliver4440 posted on 2019-1-18 16:41 I have just solved this problem. The reason is that it is not implemented, but the reason for not being implemented is because I wrote it between an #if and #endi ...
The #if instruction is followed by a condition, and it will only be compiled if the condition is met. The condition is more complicated than the if statement in the program. Sometimes if you make a mistake by mistake, it will not compile.
This post is from ARM Technology
 
 
 

2

Posts

0

Resources
6
 
https://devzone.nordicsemi.com/f ... eferred-from-main-o This website answers the question...The answer is in the last sentence. In simple terms, you need to add this code in config.h: #ifndef PWM_ENABLED #define PWM_ENABLED 1 #endif #ifndef PWM0_ENABLED #define PWM0_ENABLED 1 #endif #ifndef PWM1_ENABLED #define PWM1_ENABLED 1 #endif #ifndef PWM2_ENABLED #define PWM2_ENABLED 1 #endif You need to define PWM0_ENABLED in config. I am also working on this smart bracelet project recently. If you can, add my QQ 840693710 for communication.
This post is from ARM Technology
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list