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.

MSP430FR5972: State machine implementation

Part Number: MSP430FR5972

Can anyone send me an example of a code implementation of state machine in .c for microcontroller 

  • Hi Pk!

    This question is very generic. In general, a state machine could be a simple switch-case based program flow:

    uint8_t state = 0;
    
    switch( state )
    {
      case 0:
      {
        // Do something
    
       state = 1;
    
        break;
      }
    
      case 1:
      {
        // Do something
    
        if( something )
        {
          state = 2;
        }
        else
        {
          state = 0;
        }
        
        break;
      }
    
      case 2:
      {
        // Do something
    
        state = 0;
    
        break;
      }
    
      default: break
    }

    Dennis

  • Thank you Dennis,

    I am attaching a S/w flow diagram

    can you plz help me according to this file 

    ETS SW Flow diagram.pdf

  • The diagram looks quite good and well-organized, but it is quite a lot. I think you should start by yourself and come back when things do not work as expected or when you have questions about something because now it has become very specific to the hardware you will use and it is definitely no beginner project. This is a bit of programming.

**Attention** This is a public forum