小弟最近刚刚接触C6000写了一个程序,一会发下来,我发现当定时器计数的时候,MCBSP就发不出来数了。
但是把定时器和中断关掉,MCBSP立刻就可以出来数据= =
附程序:
//#include <math.h>
#include <csl.h>
#include <stdio.h>
#include <std.h>
#include <csl_irq.h>
#include <csl_emif.h>
#include <csl_mcbsp.h>
#include <emif_init.h>
#include <mcbsp_init.h>
#include <time_init.h>
/************************************************/
Uint32 *Src_StartAdd;
Uint32 *Dst_StartAdd;
Uint32 TempData[4096];
Uint32 Length=0x00001000;
/**************MCBSP*************************/
static MCBSP_Handle hMcbsp0; //句柄设置
static MCBSP_Handle hMcbsp1; //句柄设置
/**************************定时器****************/
static Uint32 TimerControl;
static Uint32 TimerPeriod;
static Uint32 TimerCount;
static TIMER_Handle hTimer1;
static Uint32 TimerEventId;
#define TIMER_CNT 100
#define FALSE 0
#define TRUE 1
//static Uint32 cnt = 0;
static Uint32 y=0;
static Uint32 i=0;
static Uint32 cnt = 0;
void TimerEventHandler(void);
extern far void vectors(); //中断向量表
void startMCBSP(void); //串口打开
//void RS422_transfer();
void DINGSHIQI();
void main()
{
/**************定义****************/
volatile Uint32 x,y;
int success = 1;
DEC6701_INIT(); //EMIF初始化
DEC6701_TIMER(); //定时器初始化
CSL_init();
/**********************************/
Src_StartAdd = (Uint32 *)0x02000000;//SRAM清零
for(i=0;i<0x00400000;i++)
{
*(Src_StartAdd+i) = 0;
}
hMcbsp0 = MCBSP_open(MCBSP_DEV0, MCBSP_OPEN_RESET); //句柄设置
hMcbsp1 = MCBSP_open(MCBSP_DEV1, MCBSP_OPEN_RESET);
DEC6701_MCBSP_INIT(); //初始化MCBSP0.1
startMCBSP(); //启动MCBSP
for (y=0; y<0x00080000; y++)
{
while (!MCBSP_xrdy(hMcbsp0));//等待
MCBSP_write(hMcbsp0,y);
while (!MCBSP_rrdy(hMcbsp0));
x = MCBSP_read(hMcbsp0);
if (x != y)
{
success = 0;
break;
}
}
MCBSP_close(hMcbsp0);
printf("SUCCESS=%d",success);
// RS422_transfer();
/**************************************************
****************定时器发送****************/
DINGSHIQI();
TIMER_start(hTimer1);
while(cnt <= TIMER_CNT); /* waiting for interrupt*/
MCBSP_close(hMcbsp1);
}
void startMCBSP(void)
{
MCBSP_start(hMcbsp0,MCBSP_RCV_START | //start transmit(XRST)
MCBSP_XMIT_START | //start receive(RRST)
MCBSP_SRGR_START | //start sample rate generator(GRST)
MCBSP_SRGR_FRAMESYNC, //start frame sync.generation(FRST)
MCBSP_SRGR_DEFAULT_DELAY); //MCBSP_SRGR_DEFAULT_DELAY,0x00003000
MCBSP_start(hMcbsp1,MCBSP_RCV_START | //start transmit(XRST)
MCBSP_XMIT_START | //start receive(RRST)
MCBSP_SRGR_START | //start sample rate generator(GRST)
MCBSP_SRGR_FRAMESYNC, //start frame sync.generation(FRST)
MCBSP_SRGR_DEFAULT_DELAY); //MCBSP_SRGR_DEFAULT_DELAY,0x00003000
}
void DINGSHIQI(void)
{
hTimer1 = TIMER_open(TIMER_DEV1,TIMER_OPEN_RESET);//Open TIMER1 device, and reset them to power-on default state.
TimerEventId = TIMER_getEventId(hTimer1); //Obtain the event ID for the timer device.
IRQ_setVecs(vectors); /* point to the IRQ vector table */
IRQ_globalEnable(); /* Globally enable interrupts */
IRQ_nmiEnable(); /* Enable */
IRQ_map(TimerEventId,14);
IRQ_reset(TimerEventId);
IRQ_enable(TimerEventId);
}
/*void RS422_transfer()
{
for (y=0; y<0x00080000; y++)
{
while (!MCBSP_xrdy(hMcbsp1));//等待
MCBSP_write(hMcbsp1,y);
}
}
*/
void TimerEventHandler(void)
{
cnt++;
if (cnt > TIMER_CNT)
{
for (y=0; y<0x00080000; y++)
{
while (!MCBSP_xrdy(hMcbsp1));//等待
MCBSP_write(hMcbsp1,y);
}
}
}
interrupt void
c_int14(void)
{
TimerEventHandler();
return;
}
很简单
我总结了一下:
A:TIMER_START();
SENDDATA();
WHILE(1); 定时器工作,MCBSP不出数
B:TIMER_START();
WHILE(1)
{
SENDDATA();
}
MCBSP工作,定时器不工作
很不解- - |