和小伙伴们好几天赶到晚上两点多,是快趴下了。。。多亏有啸风这样的活雷锋帮忙
CPLD未用的管脚一定要高阻啊,流程里写了
今晚玩灯,还没系统的看F28335的得特西特,都是按位在操作,代码看上去很繁杂。
看看过几天能不能用移位去处理流水灯吧。
位定义:
#define IN 0x0
#define OUT 0x1
#define LED0_DIR GpioCtrlRegs.GPADIR.bit.GPIO18
#define LED1_DIR GpioCtrlRegs.GPADIR.bit.GPIO19
#define LED2_DIR GpioCtrlRegs.GPADIR.bit.GPIO20
#define LED3_DIR GpioCtrlRegs.GPADIR.bit.GPIO21
#define LED4_DIR GpioCtrlRegs.GPADIR.bit.GPIO22
#define LED5_DIR GpioCtrlRegs.GPADIR.bit.GPIO23
#define LED6_DIR GpioCtrlRegs.GPADIR.bit.GPIO24
#define LED7_DIR GpioCtrlRegs.GPADIR.bit.GPIO25
#define LED0_OFF GpioDataRegs.GPASET.bit.GPIO18 = 1
#define LED1_OFF GpioDataRegs.GPASET.bit.GPIO19 = 1
#define LED2_OFF GpioDataRegs.GPASET.bit.GPIO20 = 1
#define LED3_OFF GpioDataRegs.GPASET.bit.GPIO21 = 1
#define LED4_OFF GpioDataRegs.GPASET.bit.GPIO22 = 1
#define LED5_OFF GpioDataRegs.GPASET.bit.GPIO23 = 1
#define LED6_OFF GpioDataRegs.GPASET.bit.GPIO24 = 1
#define LED7_OFF GpioDataRegs.GPASET.bit.GPIO25 = 1
#define LED0_ON GpioDataRegs.GPACLEAR.bit.GPIO18 = 1
#define LED1_ON GpioDataRegs.GPACLEAR.bit.GPIO19 = 1
#define LED2_ON GpioDataRegs.GPACLEAR.bit.GPIO20 = 1
#define LED3_ON GpioDataRegs.GPACLEAR.bit.GPIO21 = 1
#define LED4_ON GpioDataRegs.GPACLEAR.bit.GPIO22 = 1
#define LED5_ON GpioDataRegs.GPACLEAR.bit.GPIO23 = 1
#define LED6_ON GpioDataRegs.GPACLEAR.bit.GPIO24 = 1
#define LED7_ON GpioDataRegs.GPACLEAR.bit.GPIO25 = 1
IO初始化及流水灯子函数:
void Gpio_init() //set gpio18-gpio25 output
{EALLOW;
LED0_DIR = OUT;
LED1_DIR = OUT;
LED2_DIR = OUT;
LED3_DIR = OUT;
LED4_DIR = OUT;
LED5_DIR = OUT;
LED6_DIR = OUT;
LED7_DIR = OUT;
LED0_OFF;
LED1_OFF;
LED2_OFF;
LED3_OFF;
LED4_OFF;
LED5_OFF;
LED6_OFF;
LED7_OFF;
EDIS;
}
void LED_GO()
{LED0_ON;
DELAY_US(300000L);
LED0_OFF;
LED1_ON;
DELAY_US(300000L);
LED1_OFF;
LED2_ON;
DELAY_US(300000L);
LED2_OFF;
LED3_ON;
DELAY_US(300000L);
LED3_OFF;
LED4_ON;
DELAY_US(300000L);
LED4_OFF;
LED5_ON;
DELAY_US(300000L);
LED5_OFF;
LED6_ON;
DELAY_US(300000L);
LED6_OFF;
LED7_ON;
DELAY_US(300000L);
LED7_OFF;
}
主函数:
void main()
{
InitSysCtrl(); //系统初始化
DINT;//关闭全局中断
InitPieCtrl();//初始化中断控制寄存器
IER = 0x0000;//关闭CPU中断
IFR = 0x0000;//清除CPU中断信号
InitPieVectTable();//初始化中断向量表
Gpio_init();
while(1)
{
LED_GO();
}
}
直接视频伺候:
视频地址:http://player.youku.com/player.php/sid/XNjI3NTU0NzA4/v.swf
一些情况:
EALLOW和EDIS,TI的DSP很有意思,相当一部分寄存器都进行了保护,所以在对相关寄存器进行配置之前,必须调用EALLOW将保护位置位,然后才能进行寄存器的配置,最后还需要调用EDIS将寄存器保护起来。
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |