MATLAB: Simulink External Mode not working on Texas Instruments C2000 Launchpad F28377S

Embedded Coderexternal modesimulinkTarget Support Package

Hi, I am trying to use Simulink r2016a "External" Simulation Mode, to run a simple Simulink program (blink LEDs at a specified rate) on a Texas Instruments C2000 Launchpad F28377S board, and monitor what is happening using scopes in Simulink.
If I can do this, then I will be able to implement and debug more complex models on the Launchpad.
I can run the "Update Diagram" check succesfully.
I can "Deploy to Hardware" succesfully – the built in LEDs on the board blink as expected.
But when I press "Run", for "External" Simulation Mode, I get the error:
" Error occurred while executing External Mode MEX-file 'ext_serial_win32_comm': Failed to connect to the target. A time-out occurred while waiting for the connection response from the target. Possible reasons for the time-out: a) The target is not switched on. b) The target is not connected to your host machine. c) The application for the model is not running on the target. You might have clicked the Stop button. If the Run button is not dimmed, click it. Otherwise, click the Build button, which downloads and runs your application on the target."
The error message is confusing, as the target is definately on, connected, and the program is running on the target.
Details of my setup:
I am using a USB cable to connect my pc to the C2000 Launchpad F28377S board.
I've attached some screenshots of relevant settings, and my code is attached.
I understand that in External Mode, the Launchpad board will send data back to Simulink on my pc over Serial communications, on the USB cable. I think there might be a setting here that I have got wrong.
Any help would be much appreciated.

Best Answer

Hi,
With the release of R2016b, support package version 16.2.2, we are now supporting external mode on all the GPIO pins that can be configured for SCI_A via the SCI_A pane (Hardware Implementation->Target Hardware Resources-> SCI_A). However, which GPIO pin for the given board needs to be selected is dependent on the board schematic. If the user has a custom designed board, then user must configure those GPIO pins for SCI_A which are routed to serial port/FTDI chip. Bottom line is, any GPIO pin which support SCI_A functionality can be configured for external mode, but which GPIO pin is used on the given board for SCI_A is for users to investigate. Some popular board from TI and their default GPIO pin assignment for SCI_A are as below:
For F28377S Launchpad, FTDI connected to GPIO pins GPIO84(Tx) and GPIO85(Rx)
For F28379D Launchpad, FTDI connected to GPIO pins GPIO42(Tx) and GPIO43(Rx)
For F28377D Controlcards,FTDI connected to GPIO pins GIO29(Tx) and GPIO28(Rx)
Selecting internal oscillator works for F28379D Launchpad for following reason: the external oscillator on this launchpad runs at 10MHz, but our default value for Oscillator clock (OSCCLK) frequency in MHz is 20MHz. This default value is true for a F28379D control card but not for launchpad. When user generates the code keeping this default value and tries to run it on Launchpad, we get incorrect value for the PLL multiplier as we are generating it for a 20MHz oscillator but launchpad has a 10MHz oscillator as noted above. This in-turn affects the calculation of other parameters like SCI baud rate which affects the external mode. However, selecting internal oscillator for the launchpad seem to do the trick, upon selection, we no more default to 20MHz but use actual value of the internal oscillator i.e 10MHz, to derive the PLL multiplier. This keeps other calculations consistent and thus external mode works. It would be better if the user is able to change the external oscillator frequency “Oscillator clock (OSCCLK) frequency in MHz” from default value of 20MHz to 10MHz if he plans to work with F28379D Launchpad against the current solution of selecting the internal oscillator.
Regards,
Venkatesh Chilapur