cancel
Showing results for 
Search instead for 
Did you mean: 

Create my own OS in C for a specific application.

NSemrHomeInit
Senior

Dear ST Hello,

Could you please help me to organize my project code for motor control?

I have several states:

  1. The init state where I initialize all the peripherals used in the project
  2. The state wait where the system is reading and working and no action are needed
  3. The close loop state motor control in closed-loop
  4. The open-loop state motor control in open loop
  5. The communication state SPI and SCI CAN...

The idea is to develop a small OS for my application. The application will be triggered by an interruption. The EPWM interrupt will be triggered every 80us and I have to loop all the states if needed otherwise loop in the wait state.

I have to create a different directory for any Driver in this project. Each driver has his own folder(.c .h inline) EPWM eCAp, ADC, SPI CAN CMPSS, and SCI..

Could you please suggest any way to organize the code? The idea is to have an extensible project for any other states, we are in the project foundations so we take time to have a good code format.

The variables have to be shared between drivers and states and we are looking to have a better way to share variables.

Any suggestion or link is welcomed. I am interested in any idea on this top.

Thank you in advance,

S.Tarik

2 REPLIES 2

>>The variables have to be shared between drivers and states and we are looking to have a better way to share variables.

Use structures, not globals

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Would you please give me an example,

For example, Ish is a current variable produced in the ADC peripharal, this variable will be used in close loop state.