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.

LAUNCHXL-F28377S: Changing Input/Output Status of GPIO Pin in Simulink during Runtime

Part Number: LAUNCHXL-F28377S

Hi all! ;)

I am advancing with the programming of my inverter (TIDA-00366)! However, there is still a problem: In the PDFs of the reference design TIDA-00366 it is mentioned that one shall change the status of one GPIO pin from input to output for a short time to drag the potential of the DISABLE signal down to GND. Because at power-up of the board the DISABLE potential is high and blocks all PWM signals of the gate drivers.
But my problem is that I cannot change the status of the GPIO pin during runtime in Simulink. If I have the same GPIO pin as input and output in my model, Simulink always throws an error when compiling the C code. Even when I use enabled subsystems to prevent the input and output block of the one GPIO to be active at the same time.
Do you know how I could solve the problem? I attached images of the schematics that may help you to understand my problem.

PS: I cannot set the GPIO status to output all the time because then the MCU would dictate the potential of the DISABLE signal. But the DISABLE signal should be set high by the logic gate during operation of the inverter (if an error occurs).

Best regards,
Armin

  • Hi Armin,

    You thread will be answered by experts from Mathworks soon. Thanks.

    Best regards,
    Chen
  • Hi Chen,

    Thanks for the professional support! I should maybe add the following information about my setup:
    I am using MATLAB R2017a and the TI C2000 Support Package version 17.1.2. And I have CCSv6 installed.

    Best regards,
    Armin

  • Hi Armin,

    You can use the memory copy block to write to GPIO register to change its direction.
    We provide an use case example of the same in the shipped model c28035pmsmfoc_cla/Hall Sensor B.
    HTH,

    Regards,
    Venkatesh C
  • Hi Venkatesh,

    Thanks for the answer! I have now implemented some Memory Copy blocks to read and write to the GPIO registers. But my model does not work as planned. I will soon add some screenshots and explain what is not working.

    Best regards,
    Armin

  • Hi Venkatesh,

    Thanks for the answer! I have now implemented some Memory Copy blocks to read and write to the GPIO registers. But my model does not work as planned.
    The model receives a signal via SCI connection from my host PC which is an uint16 with the values 0 or 1.
    If the SCI signal is 1, an enabled subsystem shall be executed that goes through a startup sequence and shall set GPIO71 as output pin and set its potential to LOW.
    If the SCI signal is 0, a different enabled subsystem is executed that sets the GPIO state back to input.
    However, the pin GPIO71 does not change its potential when I change the SCI signal values from 0 to 1 and back on my host PC.
    I attached a few screenshots of my model, maybe you can see an error? I configured all other blocks (for example other Memory Copy blocks) in the same way I configured the ones shown in the screenshots.

    Did I write all the source code symbols correctly? Or what else could be a potential cause of this erroneous behaviour?

    Best regards,
    Armin

    Root Model:

    Enabled subsystem with startup sequence:

    Block "Memory Copy of I/O Status":

    Block "Memory Write to set Output Status":

  • Hi Armin,

    Did you investigate the generated code and see if it is inline with the model that you have put up?

    Since you are changing the direction of the GPIO pad and not really reading the state of the pin, as an alternate, you can use the system outputs block as well.

    please find the image below in which system outputs block is used to generate the code that would set the GPIO pad to output.

    This code will be generated inside the model step function with an 'if' condition around the received SCI message.

    HTH

    Regards,

    Venkatesh C

  • Hi Venkatesh,

    Thanks for the help! I really like having direct access to the compiled code by using this "System Outputs" block!
    However, writing my code manually into this block has no effect. Instead of shifting and masking operations I am now directly accessing the bit for GPIO71.
    What really confused me when I looked over the not working C code is the following: Everytime the Simulink Coder changes the I/O status of GPIOs by changing values in the "GpioCtrlRegs", the code generation inserts the expression "EALLOW;" at the start of one block and the expression "EDIS;" at the end.
    Do I have to write these commands, too? I will test this soon.

    Best regards,
    Armin

    EDIT: It works when I use EALLOW; and EDIS;! Thank you very much for the detailed help! ;)