社区导航

 

搜索
查看: 31|回复: 0

[资料分享] TMS320F28335GPIO实例——点亮发光二极管

[复制链接]

5667

TA的帖子

19

TA的资源

一粒金砂(高级)

Rank: 3Rank: 3

发表于 2019-11-6 20:52 | 显示全部楼层 |阅读模式

电路原理图如下所示:

360截图20191106205234699.jpg

代码:
#include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"   // DSP2833x Examples Include File
 
#define      LED1    GpioDataRegs.GPBDAT.bit.GPIO60
#define      LED2    GpioDataRegs.GPBDAT.bit.GPIO61
 
interrupt void ISRTimer0(void);
void configtestled(void);
Uint16  i;
 
void main(void)
{
   InitSysCtrl();
 
   InitXintf16Gpio();
   DINT;
 
   InitPieCtrl();
 
// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;
   InitPieVectTable();
 
   EALLOW;  // This is needed to write to EALLOW protected registers
   PieVectTable.TINT0 = &ISRTimer0;            //配置中断函数地址
   //PieVectTable.XINT13 = &cpu_timer1_isr;
   //PieVectTable.TINT2 = &cpu_timer2_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers
 
   InitCpuTimers();   // For this example, only initialize the Cpu Timers
 
   // Configure CPU-Timer 0, 1, and 2 to interrupt every second:
   // 150MHz CPU Freq, 1 second Period (in uSeconds)
   ConfigCpuTimer(&CpuTimer0, 150, 1000000);   //配置定时时间  1s
   //ConfigCpuTimer(&CpuTimer1, 150, 1000000);
   //ConfigCpuTimer(&CpuTimer2, 150, 1000000);
    StartCpuTimer0();                          //定时器计数
 
// Enable CPU int1 which is connected to CPU-Timer 0, CPU int13
// which is connected to CPU-Timer 1, and CPU int 14, which is connected
// to CPU-Timer 2:
    IER |= M_INT1;
   //IER |= M_INT13;
   //IER |= M_INT14;
 
// Enable TINT0 in the PIE: Group 1 interrupt 7
    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;//使能PIE中断
    
// Enable global Interrupts and higher priority real-time debug events:
    EINT;   // Enable Global interrupt INTM
    ERTM;   // Enable Global realtime interrupt DBGM
    configtestled();
    LED1 = 0;
    LED2 = 0;
    i = 0;
    for(; ;)
    {   
    }
 
}
 
interrupt void ISRTimer0(void)
{
    CpuTimer0.InterruptCount++;
 
   // Acknowledge this interrupt to receive more interrupts from group 1
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;//PIEACK清0
    CpuTimer0Regs.TCR.bit.TIF=1;           //外设中断标志位清0
    CpuTimer0Regs.TCR.bit.TRB=1;           //重新装载
 
    LED1=~LED1;
    LED2=~LED2;
}
 
void configtestled(void)
{
   EALLOW;
   GpioCtrlRegs.GPBMUX2.bit.GPIO60 = 0; // GPIO60 = GPIO60配置为普通数字IO
   GpioCtrlRegs.GPBDIR.bit.GPIO60 = 1;  // 方向为输出
   GpioCtrlRegs.GPBMUX2.bit.GPIO61 = 0; // GPIO61 = GPIO61
   GpioCtrlRegs.GPBDIR.bit.GPIO61 = 1;
   EDIS;
}
 
//===========================================================================
// No more.
//===========================================================================

烧写程序后会发现LED1和LED2周期性交替闪烁!
 



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

关闭

站长推荐上一条 /5 下一条

  • 论坛活动 E手掌握

    扫码关注
    EEWORLD 官方微信

  • EE福利  唾手可得

    扫码关注
    EE福利 唾手可得

Archiver|手机版|小黑屋|电子工程世界 ( 京ICP证 060456 )

GMT+8, 2019-11-14 20:11 , Processed in 0.084842 second(s), 18 queries , Gzip On, MemCache On.

快速回复 返回顶部 返回列表