Open ElecTroMagicX opened 4 years ago
I've almost completely copied this
"esp/ESP8266_RTOS_SDK/examples/peripherals/pwm/main/pwm_example_main.c"
And the compilation was successful
but still has no output and is always low level.
#include "f_s_pwm.h" static const char *TAG = "main"; void app_main() { usr_pwm_init(); usr_pwm_start(); int cnt = 0; while (1) { vTaskDelay(5000 / portTICK_PERIOD_MS); ESP_LOGI(TAG, "cnt: %d\n", cnt++); } }
#include "f_s_pwm.h" //pwm_init(uint32_t period, uint32_t *duties, uint8_t channel_num, const uint32_t *pin_num); #define PWM_PERIOD (1000) uint8_t channel_num = 1; uint32_t duties[1] = {500}; const uint32_t pin_num[1] = {4}; //NodeMCU----D2 int16_t phase[1] = {0}; void usr_pwm_init() { esp_err_t pwminit = pwm_init(PWM_PERIOD, duties, 1, pin_num); pwm_set_phases(phase); ESP_LOGI("PWM", "PWM_INIT: %d/n", pwminit); } void usr_pwm_start() { esp_err_t pwmstart = pwm_start(); ESP_LOGI("PWM", "PWM_START: %d/n", pwmstart); }
#ifndef __F_S_PWM_H_ #define __F_S_PWM_H_ #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include "esp_log.h" #include "driver/pwm.h" void usr_pwm_init(); void usr_pwm_start(); #endif
I have this problem too
I've almost completely copied this
"esp/ESP8266_RTOS_SDK/examples/peripherals/pwm/main/pwm_example_main.c"
And the compilation was successful
but still has no output and is always low level.
main.c
f_s_pwm.c
f_s_pwm.h