/***********************************************************************/
/* */
/* FILE :sh_fir.c */
/* DATE :Wed, Dec 17, 2003 */
/* DESCRIPTION :Main Program */
/* CPU TYPE :Other */
/* */
/* This file is generated by Renesas Project Generator (Ver.3.0). */
/* */
/***********************************************************************/
#include "7047s.h"
#include "initSH.c"
#ifdef __cplusplus
//#include <ios> // Remove the comment when you use ios
//int ios_base::Init::init_cnt; // Remove the comment when you use ios
#endif
#ifdef __cplusplus
extern "C" {
#endif
void abort(void);
#ifdef __cplusplus
}
#endif
#include <machine.h>
short data;
#define N 61 //fir taps Nは奇数にする事
short fir[61]={
//; ----------------------------------------------------------
//; Band(1) Low:0.00000 High:0.20000 R= 9.980895E-05
//; Band(2) Low:0.30000 High:0.50000 R= -98.79285
//;----------------------------------------------------------
0,0,0,0,
0,0,0,-1,
0,1,0,-3,
0,4,0,-7,
0,11,0,-16,
0,24,0,-37,
0,58,0,-104,
0,324,512,324,
0,-104,0,58,
0,-37,0,24,
0,-16,0,11,
0,-7,0,4,
0,-3,0,1,
0,-1,0,0,
0,0,0,0,
0
};
short data_up[61]={0};
short data_low[61]={0};
void kakunou(unsigned char j,int data3)
{
data_up[60-j]=data3;
data_low[60-j]=data3;
}
int data_chukan;
unsigned char i=0;
void main(void)
{
InitSH();
i=0;
while(1)
{
PE.DRL.BIT.B12=1; //DA変換器用タイミング
if (AD0.ADCSR.BIT.ADF)
{
AD0.ADCSR.BIT.ADF=0;
AD0.ADCR.BIT.ADST=0;
data=AD0.ADDR0.WORD;
data
-=0x82C0;
data=data>>6;////10ビットが有効
kakunou(i,data);
data_chukan=macw(
(data_up+i),fir,61); //macwは、組み込み関数 machine.hで定義済み
data_chukan=data_chukan>>10;
//ここの出力が、要調整?
data =data_chukan;
data +=0x82C0;
PE.DRL.WORD
=data;
i++;
if( i==61) i=0;
AD0.ADCSR.BIT.ADF=0;
AD0.ADCR.BIT.ADST=1;
}
PE.DRL.BIT.B12=0; //DA変換器用タイミング
}
}
void abort(void)
{
}