Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to pwm_init #3

Closed
MatjazBostic opened this issue Sep 21, 2016 · 2 comments
Closed

undefined reference to pwm_init #3

MatjazBostic opened this issue Sep 21, 2016 · 2 comments

Comments

@MatjazBostic
Copy link

I get this error:

Compiling 'pwmTest' for 'NodeMCU 1.0 (ESP-12E Module)'
pwmTest.cpp.o: (.text.setup+0xc): undefined reference to pwm_init(unsigned int, unsigned int*, unsigned int, unsigned int (*) [3])
pwmTest.cpp.o: (.text.setup+0x10): undefined reference to pwm_start()

pwmTest.cpp.o: In function setup
pwmTest.ino:23: undefined reference to pwm_init(unsigned int, unsigned int*, unsigned int, unsigned int (*) [3])
pwmTest.ino:24: undefined reference to pwm_start()

collect2.exe*: error: ld returned 1 exit status

Error compiling for board NodeMCU 1.0 (ESP-12E Module)

pwmTest.ino:

#include<pwm.h>

#define PWM_CHANNELS 1
const uint32_t period = 5000; // * 200ns ^= 1 kHz

                              // PWM setup
uint32 io_info[PWM_CHANNELS][3] = {
    // MUX, FUNC, PIN
    { PERIPHS_IO_MUX_MTDI_U,  FUNC_GPIO12, 12 }
};

// initial duty: all off
uint32 pwm_duty_init[PWM_CHANNELS] = { 0 };

void setup() {
    pwm_init(period, pwm_duty_init, PWM_CHANNELS, io_info);
    pwm_start();
}

void loop() {

}

I have found "core_esp8266_wiring_pwm.c" in Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266 and replaced its contents with your code.

What am I doing wrong?

@StefanBruens
Copy link
Owner

Your makefile is incorrect. Remove any "-lpwm" statement and add "pwm.o" instead.

This is not specific to this code, please read up about makefiles and linker statements.

@MatjazBostic
Copy link
Author

MatjazBostic commented Sep 22, 2016

@StefanBruens Do I have to install complete esp8266 sdk to use this file? (I am using Arduino right now)

@2bedom 2bedom mentioned this issue May 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants