MATLAB-DSP官方例程------GPIO 点灯

MATLAB C2000----- 例程(一)GPIO点灯


官方链接[MATLAB 点灯]

(一)模型

请添加图片描述

前面模块为时间模块 后面为gpio口 设置了翻转模式 这个为最简单的模式

请添加图片描述

(二)烧入过程

  1. "CTRL+E"打开设置

请添加图片描述

  1. 选择一下设置之后,准备烧入板卡

请添加图片描述

  1. 等待一段时间会在你的工作路径下生成对应的文件当然会生成ccs代码

请添加图片描述

(三)物理现象

请添加图片描述

(四)代码分析

/*
 * File: ert_main.c
 *
 * Code generated for Simulink model 'c28379D_cpu1_blink'.
 *
 * Model version                  : 2.0
 * Simulink Coder version         : 9.5 (R2021a) 14-Nov-2020
 * C/C++ source code generated on : Wed Aug  4 22:46:51 2021
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Texas Instruments->C2000
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "c28379D_cpu1_blink.h"
#include "rtwtypes.h"

volatile int IsrOverrun = 0;
static boolean_T OverrunFlag = 0;
void rt_OneStep(void)  		// 该函数放在定时器当中的
{
    //启延时作用
  /* Check for overrun. Protect OverrunFlag against preemption */
  if (OverrunFlag++) {
    IsrOverrun = 1;
    OverrunFlag--;
    return;
  }
//开启定时器中断
  enableTimer0Interrupt();
//io口电平翻转函数    
  c28379D_cpu1_blink_step();

  /* Get model outputs here */
  disableTimer0Interrupt();
  OverrunFlag--;
}

volatile boolean_T stopRequested; // 
volatile boolean_T runModel;
int main(void)
{
   //状态标志位
  float modelBaseRate = 1.0;
    晶振时钟频率
  float systemClock = 200;

  /* Initialize variables */
  stopRequested = false;
  runModel = false;
    //烧入flash
  c2000_flash_init();
    //板子外设初始化
  init_board();

#ifdef MW_EXEC_PROFILER_ON
// 暂时不知道是干什么的{可能为调试}
  config_profilerTimer();

#endif

  ;
  rtmSetErrorStatus(c28379D_cpu1_blink_M, 0);//初始化标志位
  c28379D_cpu1_blink_initialize();//初始化在simulink中设置的初始化
  globalInterruptDisable();
  configureTimer0(modelBaseRate, systemClock);
  runModel =
    rtmGetErrorStatus(c28379D_cpu1_blink_M) == (NULL);
  enableTimer0Interrupt();
  globalInterruptEnable();
  while (runModel) {
    stopRequested = !(
                      rtmGetErrorStatus(c28379D_cpu1_blink_M) == (NULL));
  }

  /* Disable rt_OneStep() here */

  /* Terminate model */
  c28379D_cpu1_blink_terminate();
  globalInterruptDisable();![请添加图片描述](https://img-blog.csdnimg.cn/94f4474ed20a4071807b78fb9f2a540f.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1N0ZXZlbl9uZXdfaA==,size_16,color_FFFFFF,t_70)

  return 0;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
​	详细代码需要自己区理解
  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值