⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.c

📁 利用ti54x系列dsp编解码dtmf源程序的第三版
💻 C
字号:
/*************************************************************
*   (C) COPYRIGHT TEXAS INSTRUMENTS, INC. 1996               *
**************************************************************
*   Program Name:     DTMF tone decoder                      *
*   File Name:        init.c                                 *
*   File Description: functions for SP0, SP1, AIC inits      *
*                                                            *
*   Author:   Gunter Schmer                                  *
*   Date:     03/24/97                                       *
*   Revision: 3.0                                            *
*   Latest working date: 03/24/97                            *
*************************************************************/

#include "mmregs.h"

#define	setIntMaskBit	asm("	ssbx	INTM")
#define	clrIntMaskBit	asm("	rsbx	INTM")
#define waitForInt	asm("	idle	1")

/* AC01 register values */
#define REG1value	0x124	/* sampling rate = 8kHz */
#define REG2value	0x212	/* prescaler clk = 288kHz */
#define REG3value	0x300	/* phase adjustments: none */
#define REG4value	0x426	/* GAINS: -8dB (monitor)       */
				/*        -6dB (analog input)  */
				/*        -6dB (analog output) */

/* global ports */
ioport unsigned port14;		/* Target Control Register */



void initInts(unsigned int valueIMR)
{
  *IMR_REG |= valueIMR;		/* allow only ...             */
  *IFR_REG = 0xFFFF;		/* clear all pending flags    */
  clrIntMaskBit;		/* globally enable interrupts */
}


void initWSGen(void)
{
  /***** init waitstate generator *****/
  *SWWSR_REG = 0x2000;		/* 0 WS for memory, 2 WS for I/O  */
  *BSCR_REG = 0x0000;		/* no bank switching              */
}


void initSP0(void)
{
  /***** init Serial Port 0 ***********/
  *TCR_REG = 0x0010;		/* turn timer off			*/
  *SPC0_REG = 0xC008;		/* reset SP0				*/
				/*     =0 (b0) : reserved, always zero	*/
				/* DBL =0 (b1) : loopback mode disabled	*/
				/* FO  =0 (b2) : 16-bit word operation	*/
				/* FSM =1 (b3) : frame sync control	*/
				/* MCM =0 (b4) : external CLKX		*/
				/* TXM =0 (b5) : external FSK		*/
				/* XRST=0 (b6) : Xmit reset		*/
				/* RRST=0 (b7) : Recv reset		*/
  *SPC0_REG = 0xC0C8;		/* take SP0 out of reset		*/
				/* XRST=0 (b6) : Xmit reset		*/
				/* RRST=0 (b7) : Recv reset		*/

  *DXR0_REG = 0x0;              /* clear DXR0 				*/
  *DRR0_REG;                    /* clear DRR0 by doing a read		*/
}



void initSP1(void)
{
  /***** init Serial Port 0 ***********/
  *TCR_REG = 0x0010;		/* turn timer off			*/
  *SPC1_REG = 0xC008;		/* reset SP1				*/
				/*     =0 (b0) : reserved, always zero	*/
				/* DBL =0 (b1) : loopback mode disabled	*/
				/* FO  =0 (b2) : 16-bit word operation	*/
				/* FSM =1 (b3) : frame sync control	*/
				/* MCM =0 (b4) : external CLKX		*/
				/* TXM =0 (b5) : external FSK		*/
				/* XRST=0 (b6) : Xmit reset		*/
				/* RRST=0 (b7) : Recv reset		*/
  *SPC1_REG = 0xC0C8;		/* take SP1 out of reset		*/
				/* XRST=0 (b6) : Xmit reset		*/
				/* RRST=0 (b7) : Recv reset		*/

  *DXR1_REG = 0x0;              /* clear DXR1 				*/
  *DRR1_REG;                    /* clear DRR1 by doing a read		*/
}


void initAC01(void)
{
  setIntMaskBit;		/* globally disable interrupts */
  port14 &= 0x7FFF;		/* reset AIC */
  asm("\t rpt	#40");
  asm("\t nop");		/* wait for a while */
  port14 |= 0x8000;		/* take AIC out of reset */

  *IMR_REG = *IMR_REG | 0x0080;	/* enable TINT1 */
  *IFR_REG = 0x00C8;		/* clear pending SP1 and timer ints */
  clrIntMaskBit;		/* globally enable interrupts */
  *DXR1_REG = 0x0;		/* dummy transmit */

  *DXR1_REG = 0x3;		/* 2ndary comm request 	*/
  waitForInt;			/* wait for interrupt  	*/
  *DXR1_REG = REG1value;	/* SAMPLING RATE: 8kHz  */
  waitForInt;			/* wait for interrupt  	*/

  *DXR1_REG = 0x3;		/* 2ndary comm request 	*/
  waitForInt;			/* wait for interrupt  	*/
  *DXR1_REG = REG2value;	/* PRESCALER		*/
  waitForInt;			/* wait for interrupt	*/

  *DXR1_REG = 0x3;		/* 2ndary comm request	*/
  waitForInt;			/* wait for interrupt	*/
  *DXR1_REG = REG3value;	/* PHASE ADJUSTMENTS	*/
  waitForInt;			/* wait for interrupt	*/

  *DXR1_REG = 0x3;		/* 2ndary comm request	*/
  waitForInt;			/* wait for interrupt 	*/
  *DXR1_REG = REG4value;	/* setup GAINS		*/
  waitForInt;			/* wait for interrupt 	*/

  setIntMaskBit;		/* globally disable interrupts */
  *IMR_REG = *IMR_REG & ~0x0080;/* disable TINT1 */
  *DXR1_REG = 0x0;		/* clear DXR1 */
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -