文章目录

  • tips
  • 一 项目的搭建
    • 1.1 说明
    • 1.2 建立步骤
  • 二 LED闪烁代码
    • 2.1 Launch Code Composer Studio (CCS) and Open Resource Explorer
    • 2.2 Resource Explorer: Examples
    • 2.3 LED闪烁的代码
    • 2.4 编译,然后点击Debug
  • 3 LED闪烁的代码:通过中断定期让GPIO发生翻转
  • 另外一个相同的实现

tips

本文章关于项目搭建的内容来自:以TMS320F28069为例,如何使用CCS建立DSP工程文件


一 项目的搭建

1.1 说明

CCS使用9.1版本,DSP型号为TMS320F28069。使用其他芯片配置过程类似。

1.2 建立步骤

1.首先点击project->New CCS Project
2.选择器件和创建工程名

第3步中我选的是100v3 USB,后面无法连接到板子,所以我在项目属性那里更改为100v2 USB

测试一下是否可以连接:

如果出现了"The JTAG DR Integrity scan-test has succeeded",表示连接成功

1)选择你的目标处理器信号;
2)选择目标处理器具体的信号
3)选择下载器,如果不确定可以点击Verify确定是否连接正确
4)Porject name按照自己的喜好确定工程名称,我习惯项目名+处理器型号+版本号
按照上述设置完成以后单击finish。
3.找到要用的文件headers和common,建议安装controlSUIT。

 controlSUIT的下载地址:https://www.ti.com.cn/tool/cn/CONTROLSUITE
大概是2.4G,下载后解压,安装

复制到新建工程的目录

4.为添加的文件添加路径
在所建立的工程文件(如图标记1)处右击选择Properties.

在打开的设置界面中,将添加的common和header中的include文件夹按照下述步骤加入工程文件

上面是点击添加的按钮,然后在弹出的对话框里面直接点击Workspace…,然后选中项目中对应的comm的include和headers的include

5.删除common下cmd里的所有文件,否则会出现内存分配问题
6.删除common/source下的F2806x_SWPrioritizedPieVect.c和F2806x_SWPrioritizedDefaultIsr.c,否则会出现重复定义问题
7.将Header文件夹下CMD文件中的DSP2806x_Headers_nonBIOS.cmd保留,删除DSP2806x_Headers_BIOS.cmd。保证系统工作在无操作系统模式。如果使用的BIOS系统,则删除第一个。
8.接下来便可以编译通过运行了。


二 LED闪烁代码

TI的CCS里面自带了很多例子的代码,下面是官方的指导,怎么去获取这些代码,包括本项目用的LED闪烁代码。

原始链接:
https://dev.ti.com/tirex/explore/node?node=ANJXzL69ZqXoHLjas70yCQ__FUz-xrs__LATEST

2.1 Launch Code Composer Studio (CCS) and Open Resource Explorer

  1. Launch CCS with the Code Composer Studio desktop icon

  2. Specify a location for your workspace when prompted. This is where your projects will be located. Use a path that does NOT use spaces or any non-alphanumeric characters, with the exception of the underscore character

  3. Select Browse Examples in the Getting Started page


2.2 Resource Explorer: Examples

Displays all example projects available under the Resource Explorer. This includes all available content on the remote TI server, in addition to any content you may have installed locally.

  1. Select the device or board you are working with in the Select a device or board filter box in the top left corner. For this workshop, we select F28379D

  2. Select the Bitfield examples under Software -> C2000Ware -> English -> Devices -> F28379D -> Examples

  3. Click the Download and install icon. This will make a copy of the C2000Ware package that is on the Cloud onto your local machine. This is required to import any examples into your local CCS environment

    A prompt will appear, asking for confirmation. After agreeing to the prompt, the C2000Ware will start downloading. Once the download and installation to the local environment is completed, C2000Ware will appear in the Resource Explorer, highlighted with green arrows, indicating that it is available locally (offline) on your machine.
    这一步我没做成功,提示:This package is not support on your OS


Select the timed_led_blink example under Software -> C2000Ware -> English -> Devices -> F28379D -> Examples ->Bitfield ->CPU1 and click the Import to IDE icon

This will import the project into your workspace. The project will appear in the Project Explorer view if the import is successful
这一步我没做成功,不能直接导入到CCS,下载失败了

2.3 LED闪烁的代码

因为没办法通过上面的方式下载到代码,所以我是直接打开Example_2806xLEDBlink.c,复制代码出来,然后黏贴到我的main.c文件里

2.4 编译,然后点击Debug

注意,CCS好像默认会在main入口加个断点,所以点击Debug之后,如果看到断点停在main,点击一下Resume:

然后,你就可以看到板子上的D9那个LED在闪烁。


3 LED闪烁的代码:通过中断定期让GPIO发生翻转

//###########################################################################
//
// FILE:   Example_2806xLEDBlink.c
//
// TITLE:  Timer based blinking LED Example
//
//!  \addtogroup f2806x_example_list
//!  <h1>Timer based blinking LED(timed_led_blink)</h1>
//!
//!  This example configures CPU Timer0 for a 500 msec period, and toggles the
//!  GPIO34 LED once per interrupt. For testing purposes, this example
//!  also increments a counter each time the timer asserts an interrupt.
//!
//!  \b Watch \b Variables \n
//!  - CpuTimer0.InterruptCount
//!
//! \b External \b Connections \n
//!  Monitor the GPIO34 LED blink on (for 500 msec) and off (for 500 msec) on
//!  the 2806x control card.
//
//###########################################################################
// $TI Release:  $
// $Release Date:  $
// $Copyright:
// Copyright (C) 2009-2022 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
//   Redistributions of source code must retain the above copyright
//   notice, this list of conditions and the following disclaimer.
//
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the
//   documentation and/or other materials provided with the
//   distribution.
//
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//###########################################################################//
// Included Files
//
#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File//
// Function Prototypes statements for functions found within this file.
//
__interrupt void cpu_timer0_isr(void);//
// Main
//
void main(void)
{//// Step 1. Initialize System Control:// PLL, WatchDog, enable Peripheral Clocks// This example function is found in the F2806x_SysCtrl.c file.//InitSysCtrl();//// Step 2. Initalize GPIO:// This example function is found in the F2806x_Gpio.c file and// illustrates how to set the GPIO to it's default state.//// InitGpio();  // Skipped for this example//// Step 3. Clear all interrupts and initialize PIE vector table:// Disable CPU interrupts//DINT;//// Initialize the PIE control registers to their default state.// The default state is all PIE interrupts disabled and flags// are cleared.// This function is found in the F2806x_PieCtrl.c file.//InitPieCtrl();//// Disable CPU interrupts and clear all CPU interrupt flags//IER = 0x0000;IFR = 0x0000;//// Initialize the PIE vector table with pointers to the shell Interrupt// Service Routines (ISR).// This will populate the entire table, even if the interrupt// is not used in this example.  This is useful for debug purposes.// The shell ISR routines are found in F2806x_DefaultIsr.c.// This function is found in F2806x_PieVect.c.//InitPieVectTable();//// Interrupts that are used in this example are re-mapped to// ISR functions found within this file.//EALLOW;    // This is needed to write to EALLOW protected registersPieVectTable.TINT0 = &cpu_timer0_isr;EDIS;      // This is needed to disable write to EALLOW protected registers//// Step 4. Initialize the Device Peripheral. This function can be//         found in F2806x_CpuTimers.c//InitCpuTimers();   // For this example, only initialize the Cpu Timers//// Configure CPU-Timer 0 to interrupt every 500 milliseconds:// 80MHz CPU Freq, 50 millisecond Period (in uSeconds)//ConfigCpuTimer(&CpuTimer0, 80, 500000);//// To ensure precise timing, use write-only instructions to write to the// entire register. Therefore, if any of the configuration bits are changed// in ConfigCpuTimer and InitCpuTimers (in F2806x_CpuTimers.h), the// below settings must also be updated.////// Use write-only instruction to set TSS bit = 0//CpuTimer0Regs.TCR.all = 0x4001;//// Step 5. User specific code, enable interrupts:////// Configure GPIO34 as a GPIO output pin//EALLOW;GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;EDIS;//// Enable CPU INT1 which is connected to CPU-Timer 0//IER |= M_INT1;//// Enable TINT0 in the PIE: Group 1 interrupt 7//PieCtrlRegs.PIEIER1.bit.INTx7 = 1;//// Enable global Interrupts and higher priority real-time debug events//EINT;   // Enable Global interrupt INTMERTM;   // Enable Global realtime interrupt DBGM//// Step 6. IDLE loop. Just sit and loop forever (optional)//for(;;);
}//
// cpu_timer0_isr -
//
__interrupt void
cpu_timer0_isr(void)
{CpuTimer0.InterruptCount++;//// Toggle GPIO34 once per 500 milliseconds////我之前一直用软件的角度去看代码,以为这个是赋值的意思,但其实这个是硬件中的GPIO的翻转操作//,即每次=1,会让GPIO的电平发生变化,变到另外一个状态。//比如,原先是高电平,执行一次=1,就变成了低电平了。。。。GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;//// Acknowledge this interrupt to receive more interrupts from group 1//PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}//
// End of File
//

另外一个相同的实现

https://blog.csdn.net/fsvff/article/details/117996025

#include  <DSP28x_Project.h>int main(void)
{InitSysCtrl();  //Step1EALLOW;//LED1端口配置GpioCtrlRegs.GPBMUX1.bit.GPIO34=0;//设置为通用GPIO功能GpioCtrlRegs.GPBDIR.bit.GPIO34=1;//设置GPIO方向为输出GpioCtrlRegs.GPBPUD.bit.GPIO34=0;//使能GPIO上拉电阻//LED2端口配置//LED1端口配置GpioCtrlRegs.GPBMUX1.bit.GPIO39=0;//设置为通用GPIO功能GpioCtrlRegs.GPBDIR.bit.GPIO39=1;//设置GPIO方向为输出GpioCtrlRegs.GPBPUD.bit.GPIO39=0;//使能GPIO上拉电阻EDIS;while(1){GpioDataRegs.GPBTOGGLE.bit.GPIO34=1; //LED灯翻转DELAY_US(1000000);}
}

用CCS搭建简单的F28069M工程并控制LED闪烁相关推荐

  1. 简单SOPC实例开发任务——控制led灯闪烁

    任务1:基于nios ii处理器系统控制一个led灯闪烁 硬件系统: Nios ii处理器 4KB片内ROM存储器用于存储程序代码以及程序运行空间: 4KB片内RAM存储器用于变量存储(R/W数据): ...

  2. (LattePanda)拿铁熊猫python 简单控制led闪烁(使用python 进行硬件开发)

    前言 开发环境: LattePanda(拿铁熊猫)开发板, arduino, windows10 开发语言: python3.7, 首先说一下思路,这里的控制思路是通过对mcu中烧录 Firmata协 ...

  3. 分析vue-cli@2.9.3 搭建的webpack项目工程

    前言 已经有很多分析Vue-cli搭建工程的文章,为什么自己还要写一遍呢.学习就好比是座大山,人们沿着不同的路登山,分享着自己看到的风景.你不一定能看到别人看到的风景,体会到别人的心情.只有自己去登山 ...

  4. JNI开发笔记(四)--实现一个简单的JNI工程并生成so库

    实现一个简单的JNI工程并生成so库 引 前言 1. 编写C/h文件并添加到工程 2. 修改CmakeLists.txt文件 3. 编写native-lib.cpp文件 4. 在MainActivit ...

  5. 采用Jetty搭建简单的WebApplicationServer

    分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 采用Je ...

  6. 如何在CCS中建立自己的工程

    如何在CCS中建立自己的工程 相信有很多人用了好久的CCS了,却不会建立自己的工程文件,大家要不就是在TI的例程里改,要不就是弄的工程文件路径很复杂,而且有时还会有致命的缺点--不能换路径,也就是说放 ...

  7. 前端app调起摄像头 只显示在页面_猫也能看得懂的教程之一分钟使用Vue搭建简单Web页面...

    本教程适合人群: 已经了解过过html.js.css,想深入学习前端技术的小伙伴 有前端开发经验.但是没有使用过Vue的小伙伴 有过其他编程经验,对前端开发感兴趣的小伙伴 学习本教程之后你将会: 了解 ...

  8. 搭建第一个SpringBoot工程;SpringBoot整合mybatis;SpringBoot整合Redis-cluster集群;SpringBoot整合EhCache;

    写在前头,以下内容主要是为了自己复习之用,如果你有幸看到这篇文章,请不要嫌弃某些地方有所跳跃或省略. 1. 搭建第一个SpringBoot工程 1.1 创建工程 1.2 初始pom.xml文件内容 1 ...

  9. 【CyberSecurityLearning 附】使用PHP语言搭建简单的论坛:注册功能实现+PHP个人中心设计+简单留言板

    使用PHP语言搭建简单的论坛 简单留言板 留言 个人中心           登录                验证码           注册                头像          ...

最新文章

  1. 三点到六点是几个小时_你被“8小时睡眠论”给骗了吗?!
  2. datatable筛选条件_C#利用DataView的RowFilter对DataTable进行查询筛选
  3. 协同过滤算法(天池竞赛试题)
  4. bzoj 1636 bzoj 1699: [Usaco2007 Jan]Balanced Lineup排队(RMQ)
  5. 实现模拟内存动态分区分配算法_你还在为了JVM而烦恼么?(内存结构和垃圾回收算法)...
  6. RFID(Radio Frequency Identification)技术,又称无线射频识别
  7. poj百炼nbsp;2801:填词
  8. ROS学习笔记8 —— 状态机在ROS中的实现
  9. android dialog遮挡键盘,彻底解决软键盘遮挡DialogFragment
  10. ardupilot避障代码分析
  11. 如何git命令创建一个本地分支,并提交到远程(remote)
  12. [转载] 中美德突发事件应急指挥组织结构初探
  13. 大数据矩阵计算基础(二):R、Excel、Matlab中矩阵操作
  14. 【青龙面板+诺兰2.0 网页短信验证登录+bot查询】
  15. 用python画星空图教程水粉_水粉画教程:水粉画星空教程图解
  16. (function($){...})(jQuery)、$(function(){ })和$.fn
  17. 阻塞双端消息队列 BlockingDeque(先进先出的原则管理)
  18. java表格点击添加按钮一行_JavaScript_JQuery实现动态表格点击按钮表格增加一行,功能实现:点击添加按钮,表 - phpStudy...
  19. JavaScript看这一篇就够了,简单全面一发入魂
  20. pat乙级题目—1001 害死人不偿命的(3n+1)猜想

热门文章

  1. 【封神台 - 掌控安全靶场】尤里的复仇 Ⅰ 小芳!一二三四五六七章
  2. 亚商投资顾问 早餐FM/1011国内成品油价调整迎年内首次搁浅
  3. 大一春季联赛,dfs简单题(思路)
  4. 三款骨传导耳机性价比推荐-2023年最受欢迎的骨传导牌子
  5. ant design vue日期组件怎么清空(a-range-picker,a-date-picker)
  6. 【数字图像处理】图像几何变换之 图像的极坐标变化展开鱼眼图
  7. 区块链的正确应用方式与前景
  8. [PHP]学生成绩管理系统
  9. 疫情下失业开发即时通讯软件(仿微信)-优化服务器端吞吐量
  10. 移动文件夹ubuntu