Simulink External Mode not working on Texas Instruments C2000 Launchpad F28377S
120 views (last 30 days)
emmanuel doit on 7 Oct 2016
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.
Venkatesh Chilapur on 23 Aug 2017
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.
More Answers (5)
Matthias Baert on 23 May 2017
I have found the solution to this problem. MATLAB initialises the SCI_A port badly. If one has a look in the documentation of the Launchpad one can see that the SCI_A port needs to be configured to use GPIO 42 and 43 in order to be able to communicate over USB. For me this solved the problem completely.
Matko Pecanic on 4 Jan 2018
My solution: Hi, as you can see above I had the same problem despite doing all the stuff mentioned above.
So after no more smart options I started doing random shi*. I changed from CPU1 to CPU2 in Hardware Implementation > Build options and ofcourse it did not work. So I changed it back to CPU1 and hit RUN just to make sure it still does everything as same as before, bit this time it worked :D
Brian McKay on 10 Oct 2016
Just a guess... but sometimes, CCS locks the USB port to the board because it maintains the connection. Try using the MathWorks tools to build and download, before connecting with CCS. Or if you do connect with CCS, make sure it is disconnected and releases the USB port - as both programs cant access USB port at the same time.
Matko Pecanic on 3 Jan 2018
Edited: Matko Pecanic on 3 Jan 2018
I'm using an F28379D Launchpad and did all the things mentioned above:
- set SCI_A PINS to 42 & 43
- checked "internal clock" box (it becomes 10MHz automatically)
also matched baud rate
Still getting this error:
Error occurred while executing External Mode MEX-file 'ext_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. Component:Simulink | Category:Block diagram error Unable to connect to the 'TI Delfino F2837xD' target for 'Launchpad_test3'. Component:Simulink | Category:Model error
giray uzun on 24 Feb 2018
Edited: giray uzun on 24 Feb 2018
I had the same problem. Then I have tried something and fixed. First, you need to specify GPIO_42 and GPIO_43 as Tx and Rx as in SCI_A tab. Then go `clocking` and write `Oscillator frequency in MHz` 10 instead of 20 which is the default. If it does not work, try to use internal oscillator. By the way, I am using F28379D.
All options are at ` Hardware Implementation`.
Have a nice programming.