标题:
TMS325509定时器实验 DSP实验程序
[打印本页]
作者:
WN1695173791
时间:
2019-5-10 19:12
标题:
TMS325509定时器实验 DSP实验程序
DSP实验程序
0.png
(7.22 KB, 下载次数: 224)
下载附件
2019-5-11 03:42 上传
dsp源程序如下:
/********************************************************************************/
/* 文件名: 5502_LED.c */
/* 功能描述: 通过配置GPT和GPIO以及系统中断来控制D5和D1两个指示灯交替闪烁 */
/* 从而达到验证系统GPT,GPIO以及系统中断的目的 */
/* 作者:韩敬 */
/* 版本:1.0 */
/* 时间:2006-08-09 */
/********************************************************************************/
#include <stdio.h>
#include <csl.h>
#include <csl_pll.h>
#include <csl_chip.h>
#include <csl_irq.h>
#include <csl_timer.h>
/* Define and initialize the GPT module configuration structure */
TIMER_Config MyTimerConfig = {0x0320,0x0ffff,0x0007};
/* Function/ISR prototypes */
interrupt void Timer0Isr(void);
/* Reference start of interrupt vector table */
/* This symbol is defined in file, vectors.s55 */
extern void VECSTART(void);
/* Create a TIMER_Handle object for use with TIMER_open */
TIMER_Handle hGpt;
Uint16 EventId0; // 定时器0所对应的事件ID号
Uint16 LEDMARK = 0; // 设置指示灯的开关标志
Uint16 i = 0;
Uint16 j = 0;
unsigned int timer_counter=0;
/* 通过定义宏来控制两个外围存储器映射的寄存器,从而实现对GPIO口的控制 */
#define GPIODIR (*(volatile ioport Uint16*)(0x3400))
#define GPIODATA (*(volatile ioport Uint16*)(0x3401))
void main(void)
{
/* Initialize CSL library - This is REQUIRED !!! */
CSL_init();
/* PLL configuration structure used to set up PLL interface */
// 主频为300Mhz
PLL_setFreq(4,1);
/* Set IVPH/IVPD to start of interrupt vector table */
IRQ_setVecs((Uint32)(&VECSTART));
/* Temporarily disable all maskable interrupts */
IRQ_globalDisable();
/* Open Timer 0, set registers to power on defaults */
/* And return handle of Timer 0 */
hGpt = TIMER_open(TIMER_DEV0, TIMER_OPEN_RESET);
/* Get Event Id associated with Timer 0, for use with */
/* CSL interrupt enable functions. */
EventId0 = TIMER_getEventId(hGpt);
/* Clear any pending Timer interrupts */
IRQ_clear(EventId0);
/* Place interrupt service routine address at */
/* associated vector location */
IRQ_plug(EventId0,&Timer0Isr);
/* Write configuration structure values to Timer control regs */
TIMER_config(hGpt, &MyTimerConfig);
/* Enable Timer interrupt */
IRQ_enable(EventId0);
/* Enable all maskable interrupts */
IRQ_globalEnable();
/* Start Timer */
TIMER_start(hGpt);
/* Config GPIO7 in order to ignite led D5*/
GPIODIR = 0x40; // config the GPIO7 as output pin
for(;;)
{
/* Enter system loop and waiting for interrupt */
}
}
/*定时器0的中断程序*/
interrupt void Timer0Isr(void)
{
timer_counter++;
if(timer_counter ==115)
{
timer_counter=0;
if (LEDMARK==0)
{
GPIODATA = 0x00; /* 打开指示灯D5 */
LEDMARK = 1; /*在此行设置短点*/
}
else
{
GPIODATA = 0x40; /* 打开指示灯D5 */
LEDMARK = 0; /*在此行设置短点*/
}
}
}
/************************************************************************************/
/*注意: (1) 关闭指示灯D1只是临时的,共计100*TIMECONST个指令周期 */
/* 这种临时性主要体现在关闭指示灯D1的操作是在中断处理子程序中进行的 */
/* 而且是对CPU控制寄存器的操作,由于DSP的中断保护和恢复机制 */
/* 一旦退出中断处理子程序,关闭指示灯D1的操作自动失效,即指示灯D1又自动点亮 */
/************************************************************************************/
/******************************************************************************\
* End of 5502_LED.c
\******************************************************************************/
复制代码
所有资料51hei提供下载:
5509定时器实验.7z
(6.27 MB, 下载次数: 22)
2019-5-11 03:43 上传
点击文件名下载附件
DSP实验程序
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1