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

📄 mcbspsrc.c

📁 TLV2544-2548多通道12位串行A-D转换器的原理与应用
💻 C
字号:
/*=============================================================================*/
/*All software and related documentation is provided "AS IS" and without 		 */
/*warranty or support of any kind and Texas Instruments expressly disclaims 	 */
/*all other warranties,express or implied, including, but not limited to, the  */
/*implied warranties of merchantability and fitness for a particular purpose.  */
/*Under no circumstances shall Texas Instruments be liable for any incidental, */
/*special or consequential damages that result from the use or inability to 	 */
/*use the software or related documentation, even if Texas Instruments has 	 */
/*been advised of the liability.															    */
/*																									    */
/*Unless otherwise stated, software written and copyrighted by Texas 			 */
/*Instruments is distributed as "freeware". You may use and modify this 		 */
/*software without any charge or restriction. You may distribute to others,	 */
/*as long as the original author is acknowledged.										 */
/*=============================================================================*/


/***********************************************************************/
/*																	   */
/*Function:     MCBSP1_init()                                             */
/*																	   */
/*file name:	mcbspsrc.c											   */
/*Description:  This function performs the initialization of McBSP1    */
/*		Registers.  It begins by resetting the Frame-sync Generator,   */
/*		Sample-Rate Generator, Transmitter and Receiver.  Once 		   */
/*		registers are programmed in enables the Frame-sync and Sample  */
/*		rate generators only. 										   */
/*																	   */
/*Inputs:   	Address of McBSP object.  This structure contains all  */
/*		the McBSP Registers and their desired values.  				   */
/*Outputs:  	None	                                               */
/*Returns: 		None												   */
/*Note: 		Although MCBSP_init sets up the channel, it does NOT     */
/*  	Enable the Transmitter or Receiver. This is done by modifying  */
/*		bit 0 of SPCR1(for Receiver) and SPCR2(for Transmitter).	   */
/*		The Multi-channel registers are NOT currently not programmed.  */ 
/*		Those lines were commented out simple to save cycles, because  */
/*		we currently don't use the multi-channel McBSP features.	   */
/* AUTHOR        : AAP Application Group, L. Philipose, Dallas          */
/*                 CREATED 2000(C) BY TEXAS INSTRUMENTS INCORPORATED.  */
/***********************************************************************/


#include "c5402Reg.h"             

void MCBSP1_init(MCBSP *pMcBSP) 
{     
	unsigned int i=0;
	               
    /* McBSP 1 		Place McBSP into reset */
            SPSA1_ADDR = SPCR11_SUB;        /* Clear the RRST bit */
            SPCR11_ADDR->value = pMcBSP->RegVal.SPCR1_REG & 0xFFFE;
                
            SPSA1_ADDR = SPCR21_SUB;       /* Clear the XRST FRST GRST bits */
            SPCR21_ADDR->value = pMcBSP->RegVal.SPCR2_REG & 0xFF3E;
            
            for (i=0;i<5;i++);			/*Wait for transmiter and Receiver*/
            							/*to Power Off*/
                
            SPSA1_ADDR = RCR11_SUB; 
            RCR11_ADDR->value = pMcBSP->RegVal.RCR1_REG	;
                
            SPSA1_ADDR = RCR21_SUB; 
            RCR21_ADDR->value = pMcBSP->RegVal.RCR2_REG;
                
            SPSA1_ADDR = XCR11_SUB; 
            XCR11_ADDR->value = pMcBSP->RegVal.XCR1_REG;

            SPSA1_ADDR = XCR21_SUB;
            XCR21_ADDR->value = pMcBSP->RegVal.XCR2_REG;

            SPSA1_ADDR = SRGR11_SUB;       
            SRGR11_ADDR->value = pMcBSP->RegVal.SRGR1_REG;

            SPSA1_ADDR = SRGR21_SUB;        
            SRGR21_ADDR->value = pMcBSP->RegVal.SRGR2_REG;

/*  Since we are not currently using the Multi-channel 
 *	capabilities of the McBSP, these registers will not be 
 *  programmed.
 */                
/*              SPSA1_ADDR = MCR11_SUB; 
                MCR11_ADDR->value = pMcBSP->RegVal.MCR1_REG	;
                                
                SPSA1_ADDR = MCR21_SUB; 
                MCR21_ADDR->value = pMcBSP->RegVal.MCR2_REG;
                
                SPSA1_ADDR = RCERA1_SUB;        
                RCERA1_ADDR->value = pMcBSP->RegVal.RCERA_REG;
                
                SPSA1_ADDR = RCERB1_SUB;        
                RCERB1_ADDR->value = pMcBSP->RegVal.RCERB_REG;
                
                SPSA1_ADDR = XCERA1_SUB;        
                XCERA1_ADDR->value = pMcBSP->RegVal.XCERA_REG;
                
                SPSA1_ADDR = XCERB1_SUB;        
                XCERB1_ADDR->value = pMcBSP->RegVal.XCERB_REG ;
 */
                SPSA1_ADDR = PCR1_SUB;  
                PCR1_ADDR->value = pMcBSP->RegVal.PCR_REG;
                
/*Enable Sample-Rate Generator and Fram-Sync Generator*/	   	
	   	
	   	SPSA1_ADDR = SPCR21_SUB; 					/*Choose Serial Port Control Register 2*/
   		SPCR21_ADDR->bitval.frst = 1;    		 	/*Frame-Sync generator pulled out of Reset */
  	 	SPCR21_ADDR->bitval.grst = 1;	 			/*Sample-Rate Generator pulled out of Reset */
  

}
    



⌨️ 快捷键说明

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