PWM and LED

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
mitico94
Posts: 4
Joined: Tue Sep 29, 2020 3:53 pm
Location: Torino, Italy
Has thanked: 2 times

PWM and LED

Postby mitico94 » Tue Oct 06, 2020 3:11 pm

Hi,

Why isn't it working? I have enable HAL_USE_PWM TRUE and STM32_PWM_USE_TIM3 TRUE


Thanks in advance :)

Code: Select all

#include "ch.h"
#include "hal.h"

static PWMConfig pwmcfg = {
                           10000,
                           10000,
                           NULL,
                           {
                            {PWM_OUTPUT_ACTIVE_HIGH, NULL},
                            {PWM_OUTPUT_DISABLED, NULL},
                            {PWM_OUTPUT_DISABLED, NULL},
                            {PWM_OUTPUT_DISABLED, NULL},
                           },
                           0,
                           0
};

int main(void) {

  halInit();
  chSysInit();

  palSetPadMode(GPIOA, 6, PAL_STM32_ALTERNATE(1));
///palSetPadMode(GPIOA, 6 , PAL_MODE_ALTERNATE(1));
 
  pwmStart(&PWMD3, &pwmcfg);
  pwmEnableChannel(&PWMD3, 0, 5000);

  while (true) {
    //pwmEnableChannel(&PWMD3, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD3, 5000));
       chThdSleepMilliseconds(500);
  }
}

mitico94
Posts: 4
Joined: Tue Sep 29, 2020 3:53 pm
Location: Torino, Italy
Has thanked: 2 times

Re: PWM and LED

Postby mitico94 » Tue Oct 06, 2020 4:08 pm

Solved!

In the first moment main.c did not recognize the header hal_pal_lld.h


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 9 guests