• F28335-可移植新建工程模板-基于bitfield


    前言

    实验要求利用28335芯片,重新学习一下DSP28335,并做个记录。

    值得一提的是,28335只能用寄存器开发,而不能用库函数开发,相应的也不能用Sysconfig进行图形化编程。

    步骤

    新建工程

    按照下图所示,target是开发芯片,选择28335

    connection是采用的仿真器型号,选择你使用的那一款

    配置工程名

    选择新建工程为 带main函数的空工程

    点击finish
    在这里插入图片描述

    此时工程文件夹为
    在这里插入图片描述

    工程管理

    在工程下新建src,inc,control,peripheral,cmd文件夹

    • src文件夹用于拷贝底层驱动源文件
    • inc文件夹用于拷贝底层驱动头文件
    • control文件夹用于放置控制函数,如pid,pr,digital filter以及pll等
    • peripheral文件夹用于放置外设初始化函数,如epwm初始化和adc初始化。毕竟是寄存器开发,不可能做一个项目从头开始写寄存器吧
    • cmd文件夹用于存放cmd文件

    最终工程如下图所示
    在这里插入图片描述

    拷贝底层文件

    1. 将C2000Ware_< version >\device_support\f2833x\common\include文件拷贝至inc文件夹
    2. 将C2000Ware_< version >\device_support\f2833x\common\source文件拷贝至src文件夹
    3. 将C2000Ware_< version >\device_support\f2833x\header\include文件拷贝至inc文件夹
    4. 将C2000Ware_< version >\device_support\f2833x\header\source文件拷贝至src文件夹
    5. 将C2000Ware_< version >\device_support\f2833x\header\cmd文件夹下的DSP2833x_Headers_nonBIOS.cmd文件拷贝至src文件夹
    6. 将新建工程自动生成的28335_RAM_lnk.cmd文件剪切到cmd文件夹
    7. 将工程src文件夹下的DSP2833x_SWPrioritizedDefaultIsr.c以及DSP2833x_SWPrioritizedPieVect.c鼠标右键exclude from build

    工程文件如下
    在这里插入图片描述

    在这里插入图片描述

    添加文件搜索路径${PROJECT_ROOT}\inc
    在这里插入图片描述

    添加测试函数

    /**

    • main.c
      */

    #include “DSP28x_Project.h”

    int main(void)
    {
    InitSysCtrl(); // configure SYSCLK and disable clock of all peripheral
    InitGpio(); // Configure all GPIOs at GPIO functionality, input mode and pull-up enabled
    DINT;
    // DINT equals INTM = 1, disable global interrupts.
    InitPieCtrl(); // reset pie registers
    IER = 0x0000; // disable CPU interrupt
    IFR = 0x0000; // clear CPU interrupt flag bit
    InitPieVectTable(); // reset pie vector table, you may look up vector in the function
    EINT;
    // EINT equals INTM = 0, enable global interrupts.

    /*
     *  user function start
     */
    
    while (1)
    {
        static unsigned int i = 0;
        static unsigned int j = 0;
        if (i++ > 2000 - 1)
        {
            i = 0;
            if (j++ > 2000 - 1)
            {
                j = 0;
                GpioDataRegs.GPATOGGLE.bit.GPIO0 = 1;
            }
        }
    }
    
    /*
     * user function end
     */
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    }
    interrupt void epwm1_timer_isr(void)
    {
    /*
    * user control start
    */
    static Uint16 cnt = 0;
    cnt++;
    if (cnt == 5000)
    {
    cnt = 0;
    // LED3_TOGGLE;
    }

    /*
     * user control end
     */
    
    // Clear INT flag for this timer
    EPwm1Regs.ETCLR.bit.INT = 1;
    // Acknowledge this interrupt to receive more interrupts from group 3
    PieCtrlRegs.PIEACK.bit.ACK3 = 1;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    }

    编写main.c测试函数

    /**
     * main.c
     */
    
    #include "DSP28x_Project.h"
    
    int main(void)
    {
        InitSysCtrl(); // configure SYSCLK and disable clock of all peripheral
        InitGpio(); // Configure all GPIOs at GPIO functionality, input mode and pull-up enabled
        DINT;
        // DINT equals INTM = 1, disable global interrupts.
        InitPieCtrl(); // reset pie registers
        IER = 0x0000; // disable CPU interrupt
        IFR = 0x0000; // clear CPU interrupt flag bit
        InitPieVectTable(); // reset pie vector table, you may look up vector in the function
        EINT;
        // EINT equals INTM = 0, enable global interrupts.
    
        /*
         *  user function start
         */
    
        while (1)
        {
            static unsigned int i = 0;
            static unsigned int j = 0;
            if (i++ > 2000 - 1)
            {
                i = 0;
                if (j++ > 2000 - 1)
                {
                    j = 0;
                    GpioDataRegs.GPATOGGLE.bit.GPIO0 = 1;
                }
            }
        }
    
        /*
         * user function end
         */
    }
    interrupt void epwm1_timer_isr(void)
    {
        /*
         * user control start
         */
        static Uint16 cnt = 0;
        cnt++;
        if (cnt == 5000)
        {
            cnt = 0;
    //        LED3_TOGGLE;
        }
    
    
        /*
         * user control end
         */
    
        // Clear INT flag for this timer
        EPwm1Regs.ETCLR.bit.INT = 1;
        // Acknowledge this interrupt to receive more interrupts from group 3
        PieCtrlRegs.PIEACK.bit.ACK3 = 1;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65

    编译通过

  • 相关阅读:
    SpringCloud之nacos
    电脑技巧:盘点10个非常实用且有趣的网站
    在windows中安装zipkin报错
    nodejs毕业设计源码基于node.js的博客系统
    如何优雅构建自定义 Spring Boot 验证器,让你的代码更加丝滑!
    Matlab:Matlab 软件学习之GUI图像用户界面简介(工具栏/菜单栏/对话框)、GUI界面设计案例应用(设计二级菜单栏)之详细攻略
    【UE5 Cesium】17-Cesium for Unreal 建立飞行跟踪器(2)
    【mmDetection框架解读】入门篇三、VOC数据集转COCO数据集,在MMDetection中成功运行
    java8新特性使用
    matplotlib绘制折线图
  • 原文地址:https://blog.csdn.net/xht2403267701/article/details/134022181