基于TS201的流水灯的实现【适合初学者】
0赞
发表于 7/18/2011 8:08:11 PM
阅读(2924)
很多同学在做DSP的题目,可能不知道该如何下手。VDSP的例程又挺难,这个流水灯的程序比较适合初学者研究。这个代码是基于ts201的,其他型号的芯片跟这个是大同小异的。下面是代码的一部分:
#include <sysreg.h>
#include <builtins.h>
#include "flag.h"
volatile int i, j;
int countforplot;
int countforplot;
void main(){
InitFlagAsOutput(2); /* Assign FLAG2 as an output */
InitFlagAsOutput(3); /* Assign FLAG3 as an output */
FlagHigh(2); /* Set FLAG2 high */
FlagLow(3); /* Set FLAG3 low */
InitFlagAsOutput(2); /* Assign FLAG2 as an output */
InitFlagAsOutput(3); /* Assign FLAG3 as an output */
FlagHigh(2); /* Set FLAG2 high */
FlagLow(3); /* Set FLAG3 low */
countforplot = 0;
while(1){ /* Setup infinite loop here... */
countforplot++;
if(countforplot >100)
countforplot = 5;
for(i=0; i<8000000; i++);
/* Add an arbitrary delay here */
FlagLow(2); /* Set FLAG2 low */
FlagHigh(3); /* Set FLAG3 high */
for(j=0; j<8000000; j++);
/* Add an arbitrary delay here */
FlagHigh(2); /* Set FLAG2 high */
FlagLow(3); /* Set FLAG3 low */
} /* End infinite WHILE(1) loop... */
if(countforplot >100)
countforplot = 5;
for(i=0; i<8000000; i++);
/* Add an arbitrary delay here */
FlagLow(2); /* Set FLAG2 low */
FlagHigh(3); /* Set FLAG3 high */
for(j=0; j<8000000; j++);
/* Add an arbitrary delay here */
FlagHigh(2); /* Set FLAG2 high */
FlagLow(3); /* Set FLAG3 low */
} /* End infinite WHILE(1) loop... */
} /* End of main()... */
貌似不能上传附件,有需要全部代码的可以加我的QQ:813053061。
by strongHe
