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

nRF51-DK on Mbed IDE : When one PwmOut is enabled in my project, system crashes.

Hi

I am working on nRF51-DK with Mbed IDE & used PWM example code from  link : https://os.mbed.com/handbook/PwmOut

When enabled PwmOut, PWM signal is observed on the oscilloscope but other pheripherals like UART & all  are not working. It seems like a system is crashed.

It would be grateful if anyone helps me to resolve this issue.

Regards

Bharat Gopani

Parents
  • Hi Bharat,

    the oscilloscope but other pheripherals like UART & all  are not working. It seems like a system is crashed.

    I need more information from you. 

    - Have you chosen a pin for the PWM that doesn't  get used by anything else

    (in the example you sent the LED1 is used, so that could cause an issue)

    - Send me you code

    - How do you know the system crashed, do you have any error codes and such?

     

  • Hello Martin,

    Thanks for the reply.

    Yes, system seems to be crashed.

    A pin for PWM doesn't get used anything else.

    PFB the code snippet.

    When PwmOut is not enabled, LED1 blinks every second but when I enabled the PwmOut , LED1 is not blinking at every second but PWM pulses are observed at Pin P0.16 on oscilloscope.

    Waiting for the reply.

    #include "mbed.h"
     
    PwmOut VMPWM(P0_16);  //P0.16 for the PWM 
    DigitalOut led1(LED1);        // P0.21 for LED1
     
    void periodicCallback(void) { 
        led1 = !led1;
    }    
     
    int main(void) {
     
    VMPWM.period(0.01f);                // 10 ms period
    VMPWM = 0.2f;                       // 20 % 
     
    Ticker ticker;
     ticker.attach(periodicCallback,1);     // In Seconds. 
     
    while(1);
    }
    

Reply
  • Hello Martin,

    Thanks for the reply.

    Yes, system seems to be crashed.

    A pin for PWM doesn't get used anything else.

    PFB the code snippet.

    When PwmOut is not enabled, LED1 blinks every second but when I enabled the PwmOut , LED1 is not blinking at every second but PWM pulses are observed at Pin P0.16 on oscilloscope.

    Waiting for the reply.

    #include "mbed.h"
     
    PwmOut VMPWM(P0_16);  //P0.16 for the PWM 
    DigitalOut led1(LED1);        // P0.21 for LED1
     
    void periodicCallback(void) { 
        led1 = !led1;
    }    
     
    int main(void) {
     
    VMPWM.period(0.01f);                // 10 ms period
    VMPWM = 0.2f;                       // 20 % 
     
    Ticker ticker;
     ticker.attach(periodicCallback,1);     // In Seconds. 
     
    while(1);
    }
    

Children
Related