This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432P401R: Code is not running after reset button in pressed.

Part Number: MSP432P401R

Hello,

I am using MSP432P401R to build the obstacle detection robot.

I have interfaced 3 IR sensors to detect the obstacles around the robot.I am reading the sensors' values in a while loop to monitor continuously. My problem is that, when I flash my own code it runs fine for the first time. But if I press reset button then code will not run again. To make it run i have to flash the code again.

But I have used an example code which changes the PWM signal's  duty cycle with every press of a switch, it is working fine even after pressing the reset button.

I am not sure what went wrong. I am not using any interrupt service routines in my code. I think reset button has it's own ISR.

Could you kindly let me know how to fix this.

Thanks,

Sushrut

  • Hello Sushrut,

    Could you please send me your project? Also which compiler/IDE and SDK version are you using?

    Thanks,

    David
  • Hello David,

    I am using "simplelink_msp432_sdk_1_30_00_40". The compiler version is TI v16.9.1.LTS. I have taken the "timer_a_pwm_mode" example as base project to make changes. I am using   "CCSv7 Service Release Windows 7.1.0.00016" as my IDE.

    Please find my project in the attachment.PWM_MSP_EXP432P401R_nortos_ccs.rar

  • Hello David,

    Today I have done some changes in the code. I noticed that whenever I tried to change the PWM's duty cycle in the while loop, the code works fine before pressing reset. But once when I press reset the code is not working. I had a suspect that the timer might need some delay time to change the PWM.

    So i tried to change the duty cycle outside the while loop, but no use.I have attached my project. Could you kindly look into it ?

    The main file's name is test.c

    In this file after pressing reset the duty cycle is not varying according to interrupt but it will always be 100%.

    Thanks,

    Sushrut8176.PWM_MSP_EXP432P401R_nortos_ccs.rar

  • Hi Sushrut,

      I changed your code to:

           while(1)
              {
    //           printf("entered while\n");
               pwmConfigA0.dutyCycle--;
               pwmConfigA1.dutyCycle = pwmConfigA0.dutyCycle;
    
               if (pwmConfigA0.dutyCycle == 0)
               {
                   pwmConfigA0.dutyCycle = 32000;
               }
    
    //           pwmConfigA0.dutyCycle = pwmConfigA1.dutyCycle = 32000;
    
               MAP_Timer_A_setCompareValue(TIMER_A0_BASE,
                                           TIMER_A_CAPTURECOMPARE_REGISTER_1,
                                           pwmConfigA0.dutyCycle);
    
               MAP_Timer_A_setCompareValue(TIMER_A1_BASE,
                                           TIMER_A_CAPTURECOMPARE_REGISTER_1,
                                           pwmConfigA1.dutyCycle);
    //           MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfigA0);
    //           MAP_Timer_A_generatePWM(TIMER_A1_BASE, &pwmConfigA1);
              }

    The problem is that the MAP_Timer_A_generatePWM  will reconfigure the timer and because it is inside of the loop, it will start/stop the timer continuously. The printf adds a delay enough to make this configuration to happen.

      Hopefully this helps.

         David 

  • Hello David,

    I have written a simple code in while loop as below. But it is not working.

    while(1)
    {
    printf("entered while\n");
    pin3_7_status = GPIO_getInputPinValue (GPIO_PORT_P3, GPIO_PIN7);
    if(pin3_7_status == GPIO_INPUT_PIN_LOW)
    {
    printf("Obstacle in front sensor\n");

    pwmConfigA0.dutyCycle = pwmConfigA1.dutyCycle = 0;

    MAP_Timer_A_setCompareValue(TIMER_A0_BASE,
    TIMER_A_CAPTURECOMPARE_REGISTER_1,
    pwmConfigA0.dutyCycle);
    MAP_Timer_A_setCompareValue(TIMER_A0_BASE,
    TIMER_A_CAPTURECOMPARE_REGISTER_1,
    pwmConfigA1.dutyCycle);
    }
    else
    {
    printf("No Obstacle in front sensor\n");
    pwmConfigA0.dutyCycle = pwmConfigA1.dutyCycle = 32000;

    MAP_Timer_A_setCompareValue(TIMER_A0_BASE,
    TIMER_A_CAPTURECOMPARE_REGISTER_1,
    pwmConfigA0.dutyCycle);
    MAP_Timer_A_setCompareValue(TIMER_A0_BASE,
    TIMER_A_CAPTURECOMPARE_REGISTER_1,
    pwmConfigA1.dutyCycle);
    }
    }

  • Hi Sushrut,

    What is the behavior that you are expecting?? For pwmConfigA1.dutyCycle, I believe you should use TIMER_A1_BASE

    MAP_Timer_A_setCompareValue(TIMER_A1_BASE,
     TIMER_A_CAPTURECOMPARE_REGISTER_1,
     pwmConfigA1.dutyCycle);

    Were you able to run the code that I posted??

      Best regards,

        David

**Attention** This is a public forum