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.

Hardware switching within project (CCS + Motorware)

Other Parts Discussed in Thread: MOTORWARE, DRV8301, DRV8312

Hello,

What is the preferred/envisioned method to set up a project that will run on 2 different driver boards? So based on a simple 'switch' in the project settings, it can be build it for the selected hardware.

Seeing the file/directory structure of motorware, I guess someone must have given this some thought, but I did not find info about this. Considering that it requires using different ( hal.c + hal.h + user.h ) settings / information, I am confused how to handle this in the best way.

Thanks,

Harry

(using CCS 5.5 + motorware 13)

  • Hello Harry,

    I think the one that you should concern is user.h because the content is hardware (driver) dependent.

    If you use the same peripherals setting (ADC numbers, PWM numbers, GPIO numbers, etc) for your two hardware drivers, I think hal.c and hal.h will be the same.

    Maybe you can try to switch between user1.h and user2.h using #ifdef or #define between DRIVER_X and DRIVER_Y, or using the same file user.h but border it between DRIVER_X and DRIVER_Y using #ifdef.

    I am not sure whether this is the only one you need, or there is something else that you should concern but you may try.

    Best regards,

    Maria

  • The two boards are not the same in pin layout, so hal.c also is different.

    I have thought about #define switching, but have not tried to implement that for this situation (yet).

    Now I have setup different build configurations where the include paths point to the different board directories. Also I have removed hal.c from the project tree, and put it as an include in 'main.c'. This seems to work okay, but it feels a bit clumsy, so I am interested if there is a better method.


    Best regards,

    Harry

  • This is essentially what we had to do with the initial InstaSPIN GUI.  The binary we created works on F2806xF and M devices on three very different inverters (DRV8312, DRV8301, HVMTR).

    To do this we first added some GPIO logic to detect / determine which inverter we are connected to.

    We do this at the top of main() before we initialize any of the InstaSPIN control system.

    Based on this we initialize / load different values of gUserParams...and to make it more complicated we allow you in the GUI to further change some of these values, which we then re-load.  We have a single hal.c / .h for this, but we use #define for if / else based on the inverter detection.