hi oceanx
thank you for your help.
yes, you are right,i am from P.R.C.
http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif
i have read the releated parts of the handbook,and i have try to use it as follows,
# include "excalibur.h"
# include "stdio.h"
# define clk 57600 //73140# define v 7# define outrate 6840
unsigned int Gcd(unsigned int M,unsigned int N)
{
unsigned int Rem;
while(N > 0)
{
Rem = M % N;
M = N;
N = Rem;
}
return M;
}
void main(void)
{
unsigned int wnfenzi,wnfenmu,gcd;
unsigned int rnfenzi,rnfenmu,rnzheng;
unsigned int fenzi,fenmu,faqam,qamfenzi,qamfenmu;
unsigned int inqam;
unsigned int bo,co;
//计算写时钟参数
wnfenzi=outrate*v*188;
wnfenmu=clk*204*8;
gcd=Gcd(wnfenzi,wnfenmu);
wnfenzi=wnfenzi/gcd;
wnfenmu=wnfenmu/gcd;
printf("wnfenzi=%d,wnfenmu=%d\n",wnfenzi,wnfenmu);
na_wnfenzi_pio->np_piodirection=0xffffffff;
na_wnfenmu_pio->np_piodirection=0xffffffff;
na_wnfenzi_pio->np_piodata=wnfenzi;
na_wnfenmu_pio->np_piodata=wnfenmu;
//计算读使能参数
rnfenzi=wnfenmu*47;
rnfenmu=wnfenzi*2;
if(rnfenzi>rnfenmu)
{
rnzheng=rnfenzi/rnfenmu;
rnfenzi=rnfenzi-rnfenmu*rnzheng;
if(rnfenzi==0)
{
rnfenmu=2;
}
rnfenmu=rnfenmu-1;
rnfenzi=rnzheng+rnfenzi;
}
//输出为rnfenmu(factor),rnzheng(conl_1),rnfenzi(conl_2)
printf("rnfenzi=%d,rnzheng=%d,rnfenmu=%d\n",rnfenzi,rnzheng,rnfenmu);
na_rnfenmu_pio->np_piodirection=0xffffffff;
na_rnzheng_pio->np_piodirection=0xffffffff;
na_rnfenzi_pio->np_piodirection=0xffffffff;
na_rnfenmu_pio->np_piodata=rnfenmu;
na_rnzheng_pio->np_piodata=rnzheng;
na_rnfenzi_pio->np_piodata=rnfenzi;
//计算逆速率匹配
faqam=outrate%1000;
inqam=outrate/1000;
if(faqam==0)
{
fenzi=outrate;
fenmu=clk;
}
gcd=Gcd(faqam,1000);
qamfenzi=faqam/gcd;
qamfenmu=1000/gcd;
fenzi=inqam*qamfenmu+qamfenzi;
fenmu=clk*qamfenmu;
printf("fenzi=%d,fenmu=%d\n",fenzi,fenmu);
na_fenzi_pio->np_piodirection=0xffffffff;
na_fenmu_pio->np_piodirection=0xffffffff;
na_fenzi_pio->np_piodata=10;
co=na_fenzi_pio->np_piodata;
na_fenmu_pio->np_piodata=fenmu;
bo=na_fenmu_pio->np_piodata;
}
but when i use modelsim to check the result ,i do not understand the waves.
i mean when the data are written to the pio's data register,will the pio's output be always the data? what should i do if i want to output them at a time ,after all the numbers be computed out?