dsp28335的上手试用led灯闪烁-第一篇

乔海权_429512***杭州 乔海权_429512***杭州     2022-10-08     407

关键词:

1. 本次以三兄弟的DSP28335开发板为例,看下JTAG接口,EMU0,EMU1的用途,不是很懂,不深入研究,用到再说

EMU0/1是TI芯片的JTAG才有的信号,本身不属于JTAG标准里的信号,有两个作用。

(1)设定芯片是仿真模式(上拉)还是边界扫描模式(下拉)。

(2)用做高速实时数据交换RTDX及TRACE等功能时。这个一般用户可能用不到。

所以这两个信号是双向的,这个信号一般来说不需加要buffer,直接连起来就好了,不用管他是单向还是双向。

2. 打开工程,E:\dsp\SXD_C28335\SXD28335_PRO_1_V2\Example_2833x_LEDBlink,建立一个CCXML文件,编译一下工程

3. 看下引脚原理图,28335有3组GPIO,每组GPIO最多有32个引脚,但是28335是16位的,所以每组GPIO有高低寄存器

4. GPIO寄存器

5. 代码研究一下,看了一下底层用的是C2000WARE里面的库函数。

  1 #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
  2 
  3 // Prototype statements for functions found within this file.
  4 interrupt void cpu_timer0_isr(void);
  5 
  6 void main(void)
  7 {
  8 
  9 // Step 1. Initialize System Control:
 10 // PLL, WatchDog, enable Peripheral Clocks
 11 // This example function is found in the DSP2833x_SysCtrl.c file.
 12    InitSysCtrl();
 13 
 14 // Step 2. Initalize GPIO:
 15 // This example function is found in the DSP2833x_Gpio.c file and
 16 // illustrates how to set the GPIO to it's default state.
 17 // InitGpio();  // Skipped for this example
 18 
 19 
 20 // Step 3. Clear all interrupts and initialize PIE vector table:
 21 // Disable CPU interrupts
 22    DINT;
 23 
 24 // Initialize the PIE control registers to their default state.
 25 // The default state is all PIE interrupts disabled and flags
 26 // are cleared.
 27 // This function is found in the DSP2833x_PieCtrl.c file.
 28    InitPieCtrl();
 29 
 30 // Disable CPU interrupts and clear all CPU interrupt flags:
 31    IER = 0x0000;
 32    IFR = 0x0000;
 33 
 34 // Initialize the PIE vector table with pointers to the shell Interrupt
 35 // Service Routines (ISR).
 36 // This will populate the entire table, even if the interrupt
 37 // is not used in this example.  This is useful for debug purposes.
 38 // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
 39 // This function is found in DSP2833x_PieVect.c.
 40    InitPieVectTable();
 41 
 42 // Interrupts that are used in this example are re-mapped to
 43 // ISR functions found within this file.
 44    EALLOW;  // This is needed to write to EALLOW protected registers
 45    PieVectTable.TINT0 = &cpu_timer0_isr;
 46    EDIS;    // This is needed to disable write to EALLOW protected registers
 47 
 48 // Step 4. Initialize the Device Peripheral. This function can be
 49 //         found in DSP2833x_CpuTimers.c
 50    InitCpuTimers();   // For this example, only initialize the Cpu Timers
 51 #if (CPU_FRQ_150MHZ)
 52 // Configure CPU-Timer 0 to interrupt every 500 milliseconds:
 53 // 150MHz CPU Freq, 50 millisecond Period (in uSeconds)
 54    ConfigCpuTimer(&CpuTimer0, 150, 500000);
 55 #endif
 56 #if (CPU_FRQ_100MHZ)
 57 // Configure CPU-Timer 0 to interrupt every 500 milliseconds:
 58 // 100MHz CPU Freq, 50 millisecond Period (in uSeconds)
 59    ConfigCpuTimer(&CpuTimer0, 100, 500000);
 60 #endif
 61 
 62 // To ensure precise timing, use write-only instructions to write to the entire register. Therefore, if any
 63 // of the configuration bits are changed in ConfigCpuTimer and InitCpuTimers (in DSP2833x_CpuTimers.h), the
 64 // below settings must also be updated.
 65 
 66    CpuTimer0Regs.TCR.all = 0x4001; // Use write-only instruction to set TSS bit = 0
 67 
 68 // Step 5. User specific code, enable interrupts:
 69 
 70 // Configure GPIO32 as a GPIO output pin
 71    EALLOW;
 72    GpioCtrlRegs.GPBMUX2.bit.GPIO53 = 0;
 73    GpioCtrlRegs.GPBDIR.bit.GPIO53 = 1;
 74    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;
 75    GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
 76    EDIS;
 77 
 78 // Enable CPU INT1 which is connected to CPU-Timer 0:
 79    IER |= M_INT1;
 80 
 81 // Enable TINT0 in the PIE: Group 1 interrupt 7
 82    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
 83 
 84 // Enable global Interrupts and higher priority real-time debug events:
 85    EINT;   // Enable Global interrupt INTM
 86    ERTM;   // Enable Global realtime interrupt DBGM
 87 
 88 // Step 6. IDLE loop. Just sit and loop forever (optional):
 89    for(;;);
 90 }
 91 
 92 interrupt void cpu_timer0_isr(void)
 93 {
 94    CpuTimer0.InterruptCount++;
 95    GpioDataRegs.GPBTOGGLE.all = 0x40000004; // Toggle GPIO32 once per 500 milliseconds
 96    GpioDataRegs.GPBTOGGLE.bit.GPIO53 = 1;
 97    GpioDataRegs.GPATOGGLE.bit.GPIO0 = 1;
 98    // Acknowledge this interrupt to receive more interrupts from group 1
 99    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
100 }

6. 看下GPIO的全局变量volatile struct GPIO_CTRL_REGS GpioCtrlRegs;,volatile 确保本条指令不会被编译器优化,从下面看的出来,函数库将GPIOA,GPIOB,GPIOC,的控制寄存器全部写在一起了。数据寄存器也是一样的GpioDataRegs.GPATOGGLE.bit.GPIO0 = 1;

 1 struct GPIO_CTRL_REGS {
 2    union  GPACTRL_REG  GPACTRL;   // GPIO A Control Register (GPIO0 to 31)
 3    union  GPA1_REG     GPAQSEL1;  // GPIO A Qualifier Select 1 Register (GPIO0 to 15)
 4    union  GPA2_REG     GPAQSEL2;  // GPIO A Qualifier Select 2 Register (GPIO16 to 31)
 5    union  GPA1_REG     GPAMUX1;   // GPIO A Mux 1 Register (GPIO0 to 15)
 6    union  GPA2_REG     GPAMUX2;   // GPIO A Mux 2 Register (GPIO16 to 31)
 7    union  GPADAT_REG   GPADIR;    // GPIO A Direction Register (GPIO0 to 31)
 8    union  GPADAT_REG   GPAPUD;    // GPIO A Pull Up Disable Register (GPIO0 to 31)
 9    Uint32              rsvd1;
10    union  GPBCTRL_REG  GPBCTRL;   // GPIO B Control Register (GPIO32 to 63)
11    union  GPB1_REG     GPBQSEL1;  // GPIO B Qualifier Select 1 Register (GPIO32 to 47)
12    union  GPB2_REG     GPBQSEL2;  // GPIO B Qualifier Select 2 Register (GPIO48 to 63)
13    union  GPB1_REG     GPBMUX1;   // GPIO B Mux 1 Register (GPIO32 to 47)
14    union  GPB2_REG     GPBMUX2;   // GPIO B Mux 2 Register (GPIO48 to 63)
15    union  GPBDAT_REG   GPBDIR;    // GPIO B Direction Register (GPIO32 to 63)
16    union  GPBDAT_REG   GPBPUD;    // GPIO B Pull Up Disable Register (GPIO32 to 63)
17    Uint16              rsvd2[8];
18    union  GPC1_REG     GPCMUX1;   // GPIO C Mux 1 Register (GPIO64 to 79)
19    union  GPC2_REG     GPCMUX2;   // GPIO C Mux 2 Register (GPIO80 to 95)
20    union  GPCDAT_REG   GPCDIR;    // GPIO C Direction Register (GPIO64 to 95)
21    union  GPCDAT_REG   GPCPUD;    // GPIO C Pull Up Disable Register (GPIO64 to 95)
22 };

7. 还有一些汇编指令,以后再研究吧

1 #define  EINT   asm(" clrc INTM")
2 #define  DINT   asm(" setc INTM")
3 #define  ERTM   asm(" clrc DBGM")
4 #define  DRTM   asm(" setc DBGM")
5 #define  EALLOW asm(" EALLOW")
6 #define  EDIS   asm(" EDIS")
7 #define  ESTOP0 asm(" ESTOP0")

 

arduino两个led灯交替闪烁

...行的时间,判断时间间隔,分别实现两个LED灯不同频率的闪烁 参考技术B线路出现两个闪烁这种情况都是因为信号输入不稳定导致的,我们需要判断一下LED灯之间的连接。 参考技术Cle按照医生的交替闪烁的这种情况下,就可以进... 查看详情

第三节:累计主循环次数使led灯闪烁。

开场白:上一节鸿哥提到delay()延时函数消耗的时间太长了,其它任务根本没有机会执行,我们该怎么改善?本节教大家利用累计主循环次数的方法来解决这个问题。这一节要教会大家两个知识点:第一点:利用累计主循环次数... 查看详情

arduino不使用delay的定时(灯闪烁)

看到一篇关于Arduino不使用Delay的定时灯闪烁。主要是millis()方法,这个用法非常强大,很多时候需要使用,也不用担心溢出。  //constantswon‘tchange.Usedheretosetapinnumber:constintledPin=  LED_BUILTIN;//thenumberoftheLEDpin //Vari 查看详情

arduino翻译系列-led灯闪烁

原文地址-https://www.arduino.cc/en/Tutorial/Blink闪烁这个例子展示了你能拿Arduino/Genuino板子来干的最简单的事:使开发板上的LED灯闪烁。硬件需求Arduino开发板LED(非必要)220欧电阻(非必要)电路这例程使用了大部分Arduino/Genuino开发板... 查看详情

arduino翻译系列-led灯闪烁

原文地址-https://www.arduino.cc/en/Tutorial/Blink闪烁这个例子展示了你能拿Arduino/Genuino板子来干的最简单的事:使开发板上的LED灯闪烁。硬件需求Arduino开发板LED(非必要)220欧电阻(非必要)电路这例程使用了大部分Arduino/Genuino开发板... 查看详情

dsp28335基础教程——epwm实验(呼吸灯控制)(代码片段)

0前言EPWM的实验教程来了,大家久等了。这一节的学习是非常重要且常用的,比如说SPWM,SVPWM调制算法都要用到这个功能。但由于这些调制算法都是比较高阶的,目前不适合作为基础教程,我们在做完基础教程... 查看详情

dsp28335基础教程——系统定时器cputimer(定时中断)(代码片段)

...系统定时器,实现3个LED分别以0.1s,0.5s和1s的间隔闪烁。1DSP代码(注意:查看代码时双击点进去看,否则会内容不全)。main.c/********************************************************* 查看详情

传感网灯闪烁代码

参考技术A代码seekbar。核心在于使用的类改为PWMLED,不再是LED类了。在命令行界面运行python3LED.pwn.py之后,可以看到LED灯全灭、半亮、全亮,间隔1s,交替运行。不写一行代码点亮LED灯在命令行界面使用pinout命令,输出各针脚定义... 查看详情

如何利用单片机控制一颗led灯闪烁(代码片段)

...片机入门的开始,今天目标的是利用单片机控制LED灯闪烁,下图是protues仿真电路图,图中单片机左边为系统的时钟电路和复位电路,右边是LED灯电路。 下面是实现程序:首先定义了led=P2^0口为输出端口ÿ... 查看详情

创龙dsp6748开发板led闪烁

1.首先看下DSP6748的GPIO寄存器的文档,先看下框图,有这个框图,一目了然,输入和输出很清楚2.看下寄存器部分,对应上面的图,问题在于,DSP6748有多少个GPIO?最多144个,下一个问题,startware和CSL芯片支持库之间的关系?3.看... 查看详情

stm32点亮闪烁led灯

详解请看其他博客: http://www.cnblogs.com/whik/p/6672730.htmlhttp://www.51hei.com/bbs/dpj-38605-1.html  1/*本程序实现STM开发板上LED灯红绿蓝闪烁*/2345#include"stm32f10x.h"//相当于51单片机中的#include<reg51.h>6#in 查看详情

stm32通用定时器实现led灯闪烁

刚才看了一下STM32通用定时器的教程,其实和51的定时器使用差不多。只是因为32的时钟更复杂,可操控的寄存器更多,所以写的时候可能更复杂。使用通用定时器中断的一般步骤:1、使能定时器时钟 这个需要看时钟树,使... 查看详情

dsp28335基础教程——系统定时器cputimer(定时中断)(代码片段)

...系统定时器,实现3个LED分别以0.1s,0.5s和1s的间隔闪烁。1DSP代码(注意:查看代码时双击点进去看,否则会内容不全)。main.c/************************************************************************************************@fil... 查看详情

树莓派点亮led灯需要几行代码?3行。小孩子都能学会(代码片段)

...木块一样的编程接口,那么就会既像图形化编程一样容易上手,又保持了代码编程的灵活性和简洁性。当然了,不可否认,对小孩子肯定是积木编程更加方便。闪烁的LED灯GPIOZero就是树莓派基金会推出的,面向新手的树莓派硬件P... 查看详情

嵌入式gpio初始化(代码片段)

【嵌入式】GPIO初始化1.LED灯闪烁2.按键控制LED灯闪烁1.LED灯闪烁//LED灯闪烁//GPxnCON:引脚功能,GPxnDAT:输出、输入的数据存储器#defineGPJ2CON(*(volatileunsigned 查看详情

多线程-rgb_led闪烁灯(代码片段)

目录线程RTXThreadAPI实验:RGB灯闪烁准备配置线程编译运行其他multipleinstances(多个实例)joinableThread(可接合线程)小结参考资料开始学习线程之前,你可能需要复习:☞为什么使用RTOS?☞RTX系统移植如果准备就绪,... 查看详情

求高手赐教:想做一个用cpu定时器0的中断,产生一个每隔一秒led灯闪烁一次的程序

...:想做一个用CPU定时器0的中断,产生一个每隔一秒LED灯闪烁一次的程序中断程序:interruptvoidTINT0_ISR(void)//CPU-Timer0中断函数CpuTimer0.InterruptCount++;if(CpuTimer0.InterruptCount==1)GpioDataRegs.GPACLEAR.bit.GPIOA0=1;if(CpuTimer0.InterruptCount==2)GpioDataRegs.GP... 查看详情

fpga的计数器—led灯闪烁试验(代码片段)

计数是一种最简单基本的运算,计数器就是实现这种运算的逻辑电路,计数器在数字系统中主要是对脉冲的个数进行计数,以实现测量、计数和控制的功能,同时兼有分频功能。计数器在数字系统中应用广泛,... 查看详情