Simulink External Mode not working on Texas Instruments C2000 Launchpad F28377S

73 views (last 30 days)
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.
  4 Comments
Matthias Baert
Matthias Baert on 20 May 2017
Exactly the same problem here, shame that MATLAB does not have an answer to this problem.
SIVA KRISHNA
SIVA KRISHNA on 20 Feb 2022
Please recheck the Oscillator clock frequency properly. That should solve the issue. For F2838X devices, it should be 25 MHz.

Sign in to comment.

Accepted Answer

Venkatesh Chilapur
Venkatesh Chilapur on 23 Aug 2017
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
  3 Comments
SIVA KRISHNA
SIVA KRISHNA on 20 Feb 2022
Please recheck the Oscillator clock frequency properly. That should solve the issue. For F2838X devices, it should be 25 MHz.

Sign in to comment.

More Answers (5)

Matthias Baert
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.
  4 Comments
Hassan Khalid
Hassan Khalid on 11 Apr 2021
@Matthias Baert im using arduino UNO. I am facing the same issue. Can you please guide me in similar way in this regard.

Sign in to comment.


Matko  Pecanic
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
  1 Comment
Yunjie Gu
Yunjie Gu on 30 Mar 2021
Thanks Matko, this trick works for me. I guess it might be that the code running on CPU2 are disrupting the sci communication interrput handler.

Sign in to comment.


Brian McKay
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.
-Brian
  5 Comments
ismet tin
ismet tin on 25 Mar 2017
Edited: ismet tin on 12 May 2017
Hi everybody, I have been using f28379D series. I had same problem. After checking internal clock (Hardware configuration > Clock Settings) the problem were solved . now I can work external mode. But building and downloading time is so much ( about 3 minutes) I couldnt reduce that time. ? Anyone have this problem?

Sign in to comment.


Matko  Pecanic
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
  1 Comment
SIVA KRISHNA
SIVA KRISHNA on 20 Feb 2022
Please recheck the Oscillator clock frequency properly. That should solve the issue. For F2838X devices, it should be 25 MHz.

Sign in to comment.


giray uzun
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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!