This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unable To Generate PWM Signal

Hello,

I am currently trying to generate a PWM signal on P0.00 and am not having success. If I drive P0.00 without PWM, everything works fine. Is there anything that would prevent me from using PWM on P0.00. I am currently on SDK 9 and SoftDevice S110 V8, I have also added the app_pwm.c and app_pwm.h files from SDK 10 to my project.

I am using two instances and init them in the following way:

void pwm_init(void)
{
ret_code_t err_code;

app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(400L, LED_RED, LED_GREEN);
app_pwm_config_t pwm2_cfg = APP_PWM_DEFAULT_CONFIG_1CH(400L, LED_BLUE);

/* Set the polarity of the channel. */
pwm1_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;
pwm1_cfg.pin_polarity[1] = APP_PWM_POLARITY_ACTIVE_HIGH;
pwm2_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;

/* Initialize and enable PWM. */
err_code = app_pwm_init(&PWM1,&pwm1_cfg,pwm_1_ready_callback);
APP_ERROR_CHECK(err_code);
err_code = app_pwm_init(&PWM2,&pwm2_cfg,pwm_2_ready_callback);
APP_ERROR_CHECK(err_code);

app_pwm_enable(&PWM1);
app_pwm_enable(&PWM2);
}

LED_BLUE is set to P0.00, LED_RED to P0.02, and LED_GREEN to P0.03.

The red and green LEDs on my board work great, it is only the blue LED that is having problems.

I used this same pwm_init function and other functions that set the output of the LED on the previous hardware revision of my custom board and the only thing that has changed is that the blue LED moved from P0.01 to P0.00.

I probed P0.00 on the chip using my oscilloscope and I didn't see any signal at all.

Any help anyone can provide is much appreciated.

Thanks!

-Cory

Parents
  • Thank you for the response Petter. I thought about what you said and decided to run the PWM peripheral example. It worked beautifully and controlled my blue LED flawlessly. That eased my mind on any hardware concerns and proved that it must be something in my firmware. I went back to my firmware and copy-pasted the PWM peripheral example into my main.c file and made it the first and only thing that executed. Success! It worked again. I then opened my custom led.c file and updated the pwm_init function I had there with the one from the PWM peripheral example. I also added to function to change the PWM value of the LED to my led.c file to access it from main. When I ran the firmware again I had red and green LEDs but no blue LED once again. I then decided to copy the contents of my led.c file directly into main instead of accessing them from support files. Everything began to work perfectly.

    The interesting thing about this is that I know I had everything set-up properly because I was able to manipulate the red and green LEDs. Im not sure why moving everything into main fixed the issue or if there is a way around it so that my main.c file isn't huge but I wanted to thank Petter for giving me the insight to solve my problem.

    Thanks!

    -Cory

Reply
  • Thank you for the response Petter. I thought about what you said and decided to run the PWM peripheral example. It worked beautifully and controlled my blue LED flawlessly. That eased my mind on any hardware concerns and proved that it must be something in my firmware. I went back to my firmware and copy-pasted the PWM peripheral example into my main.c file and made it the first and only thing that executed. Success! It worked again. I then opened my custom led.c file and updated the pwm_init function I had there with the one from the PWM peripheral example. I also added to function to change the PWM value of the LED to my led.c file to access it from main. When I ran the firmware again I had red and green LEDs but no blue LED once again. I then decided to copy the contents of my led.c file directly into main instead of accessing them from support files. Everything began to work perfectly.

    The interesting thing about this is that I know I had everything set-up properly because I was able to manipulate the red and green LEDs. Im not sure why moving everything into main fixed the issue or if there is a way around it so that my main.c file isn't huge but I wanted to thank Petter for giving me the insight to solve my problem.

    Thanks!

    -Cory

Children
No Data
Related