matlab 与 c2000 交互

该文详细介绍了如何使用MATLAB的EmbeddedCoderSupportPackage为TexasInstruments的C2000微处理器进行编程,包括所需软件的准备、硬件支持包的下载与配置、Simulink模型的建立与参数设置、CCS的工程导入与下载步骤,以及最终实现LED灯的亮灭控制。在过程中遇到的错误提示和解决方法也有所提及。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、前言

matlab中有Embedded Coder Support Package for Texas Instruction是 C2000 Processors,现利用matlab对TI的板子进行编程。

2、需要准备的软件

(1)Matlab最好是新版本的(大于2020a)

(2)Code Composer Studio 12.0.0

(3)controlSUITE

(4)C2000Ware_4_00_00_00

安装时路径需要全英文

3、在matlab中下载硬件支持包

点开附加功能

获取硬件支持包

下载支持包

 对支持包进行配置

随便选选就可以了

要download的都download

然后无脑next就可以了,让你添加路径你就添加。

还可以点下validata进行校验,只要能点next就没出错

然后就结束了

 

 4、打开simulink对参数进行设置

打开他 

创建一个mod

去库里找一个东西

找这个

根据你的型号选择模块这里我选C8303x中的GPIO也就是数字输出,选好了拖下来,拖到空白中。

再选个constant拖到空白中。

连起来

双击constant设置输出类型


点击模型设置

 一二三,三步走

还要点这个

继续123 三步走

最后选确定就可以了。

5、路径保存

先保存simulink模型,英文路径。

再去matlab调整工作区,和simulink一个路径就可以。

 

 点击生成代码

 这是一定会报错,报错内容:

The following error occurred during deployment to your hardware board: 

Debug Server Scripting (DSS) error: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

*** User inputs: 
    Target Configuration: C:\PROGRA~3\MATLAB\SUPPOR~1\R2022a\toolbox\target\SUPPOR~1\tic2000/CCS_CO~1/F28035~1.CCX
    Program Name: D:\Homework\demo\demo.out
    Board Name: *
    CPU Name: unspecified (connect to first CPU)

*** Starting debug session...
*** Debug Session Name: Texas Instruments XDS100v3 USB Debug Probe_0/C28xx
*** Board Name: Texas Instruments XDS100v3 USB Debug Probe_0
*** CPU Name: C28xx

*** Connecting to target...
SEVERE: C28xx: Error connecting to the target: (Error -151 @ 0x0) One of the FTDI driver functions used during the connect returned bad status or an error. The cause may be one or more of: no XDS100 is plugged in, invalid XDS100 serial number, blank XDS100 EEPROM, missing FTDI drivers, faulty USB cable. Use the xds100serial command-line utility in the 'common/uscif' folder to verify the XDS100 can be located. (Emulation package 9.8.0.00235) 

SEVERE: emulation failure occurred
SEVERE: Error connecting to the target: emulation failure occurred
SEVERE: Cannot perform operation, target is not connected.
SEVERE: Error reseting target: Cannot perform operation, target is not connected.
org.mozilla.javascript.WrappedException: Wrapped com.ti.ccstudio.scripting.environment.ScriptingException: Error reseting target: Cannot perform operation, target is not connected. (C:\PROGRA~3\MATLAB\SUPPOR~1\R2022a\toolbox\shared\SUPPOR~1\tic2000/CCS_CO~1/RUNPRO~3.JS#93)
	at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1693)
	at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:160)
	at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:204)
	at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
	at org.mozilla.javascript.gen.c1._c0(C:\PROGRA~3\MATLAB\SUPPOR~1\R2022a\toolbox\shared\SUPPOR~1\tic2000/CCS_CO~1/RUNPRO~3.JS:93)
	at org.mozilla.javascript.gen.c1.call(C:\PROGRA~3\MATLAB\SUPPOR~1\R2022a\toolbox\shared\SUPPOR~1\tic2000/CCS_CO~1/RUNPRO~3.JS)
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:340)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2758)
	at org.mozilla.javascript.gen.c1.call(C:\PROGRA~3\MATLAB\SUPPOR~1\R2022a\toolbox\shared\SUPPOR~1\tic2000/CCS_CO~1/RUNPRO~3.JS)
	at org.mozilla.javascript.gen.c1.exec(C:\PROGRA~3\MATLAB\SUPPOR~1\R2022a\toolbox\shared\SUPPOR~1\tic2000/CCS_CO~1/RUNPRO~3.JS)
	at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:503)
	at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:425)
	at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:391)
	at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:382)
	at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:179)
	at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:100)
	at org.mozilla.javascript.Context.call(Context.java:528)
	at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:450)
	at org.mozilla.javascript.tools.shell.Main.exec(Main.java:162)
	at com.ti.ccstudio.apps.internal.scripting.RunScript$1.run(RunScript.java:89)
Caused by: com.ti.ccstudio.scripting.environment.ScriptingException: Error reseting target: Cannot perform operation, target is not connected.
	at com.ti.debug.engine.scripting.Target.reset(Target.java:644)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:145)
	... 18 more
.
组件:Simulink | 类别:Block diagram 错误

 这一步就算完成了,其他的就不用管了。

6、CCS配置

打开CCS导入工程

导进去就可以了

双击这个进行设置

再去设置一下工程

选这个

没有的话就把ti-cgt-c2000_20.2.1.LTS移动到ccs\tools\compiler

再点这个

在ccs里面进行下载

选中那个文件夹进行下载

然后下载

下载时要选中

最后run就可以了

可以看到板子没亮,这时候你就知道,1代表的是灭,0代表的是亮。

7、matlab simulink下载

将1改为0,然后下载

下载的时候CCS修改参数之后一定要保存,然后退出之后去matlab下载

可以看到板子的led成功点亮

matlab发出信息

编译的顶层模型目标:

模型    操作        重新编译原因        
==============================
demo  生成和编译的代码  代码生成信息文件不存在。  

编译了 1 个模型,共 1 个模型(0 个模型已经是最新的)
编译持续时间: 0h 0m 25.921s

生成报告

评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

The hopes of the whole village

看心情打赏咯

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值