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

📄 asc0.c

📁 这是英飞凌公司基于xc166开发的foc方式控制的pmsm电机例程 非常有参加价值
💻 C
字号:
//****************************************************************************
// @Module        Asynchronous/Synchronous Serial Interface (ASC0)
// @Filename      ASC0.C
// @Project       svm.dav
//----------------------------------------------------------------------------
// @Controller    Infineon XC167CI-16F40
//
// @Compiler      Keil
//
// @Codegenerator 2.1
//
// @Description   This file contains functions that use the ASC0 module.
//
//----------------------------------------------------------------------------
// @Date          19.12.2003 11:31:19
//
//****************************************************************************

// USER CODE BEGIN (ASC0_General,1)

// USER CODE END



//****************************************************************************
// @Project Includes
//****************************************************************************

#include "MAIN.H"

// USER CODE BEGIN (ASC0_General,2)

// USER CODE END


//****************************************************************************
// @Macros
//****************************************************************************

// USER CODE BEGIN (ASC0_General,3)

// USER CODE END


//****************************************************************************
// @Defines
//****************************************************************************

// USER CODE BEGIN (ASC0_General,4)

// USER CODE END


//****************************************************************************
// @Typedefs
//****************************************************************************

// USER CODE BEGIN (ASC0_General,5)

// USER CODE END


//****************************************************************************
// @Imported Global Variables
//****************************************************************************

// USER CODE BEGIN (ASC0_General,6)

// USER CODE END


//****************************************************************************
// @Global Variables
//****************************************************************************

// USER CODE BEGIN (ASC0_General,7)

// USER CODE END


//****************************************************************************
// @External Prototypes
//****************************************************************************

// USER CODE BEGIN (ASC0_General,8)

// USER CODE END


//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************

// USER CODE BEGIN (ASC0_General,9)

// USER CODE END


//****************************************************************************
// @Function      void ASC0_vInit(void) 
//
//----------------------------------------------------------------------------
// @Description   This is the initialization function of the ASC0 function 
//                library. It is assumed that the SFRs used by this library 
//                are in its reset state. 
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    None
//
//----------------------------------------------------------------------------
// @Date          19.12.2003
//
//****************************************************************************

// USER CODE BEGIN (Init,1)

// USER CODE END

void ASC0_vInit(void)
{
  // USER CODE BEGIN (Init,2)

  // USER CODE END

  ///  -----------------------------------------------------------------------
  ///  Configuration of the ASC0 Baudrate Generator:
  ///  -----------------------------------------------------------------------
  ///  - additionally reduce serial clock to 2
  ///  - required baud rate = 9,600 kbaud
  ///  - real baud rate     = 9,615 kbaud
  ///  - deviation          = 0,160 %

  ASC0_BG        =  0x0081;      // load ASC0 baud rate time reload register

  ///  -----------------------------------------------------------------------
  ///  Configuration of the ASC0 Operation Mode:
  ///  -----------------------------------------------------------------------
  ///  - 8-bit data asychronous operation with one stop bit
  ///  - receiver is enabled

  ASC0_CON       =  0x0011;      // load ASC0 control register

  ///  -----------------------------------------------------------------------
  ///  FIFO Configuration:
  ///  -----------------------------------------------------------------------
  ///  - receive FIFO is disabled
  ///  - transmit FIFO is disabled

  ASC0_RXFCON    =  0x0102;      // load ASC0 receive FIFO control register
  ASC0_TXFCON    =  0x0102;      // load ASC0 transmit FIFO control register

  ///  -----------------------------------------------------------------------
  ///  Configuration of the used ASC0 Port Pins:
  ///  -----------------------------------------------------------------------
  ///  - P3.10 is used for ASC Transmit Data Output (TxDA0)
  ///  - P3.11 is used for ASC0 Receive data Input (RxDA0)

  ALTSEL0P3     |=  0x0400;      // select alternate output function
  P3   = (P3   & ~(uword)0x0400) | 0x0400;    //set data register
  DP3  = (DP3  & ~(uword)0x0400) | 0x0400;    //set direction register

  ///  -----------------------------------------------------------------------
  ///  Configuration of the used ASC0 Interrupts:
  ///  -----------------------------------------------------------------------

  // USER CODE BEGIN (ASC0_Function,3)
	ASC0_TIC_IR=1;
  // USER CODE END

  ASC0_CON      |=  0x8000;      // enable baud rate generator


} //  End of function ASC0_vInit


//****************************************************************************
// @Function      void ASC0_vSendData(uword uwData) 
//
//----------------------------------------------------------------------------
// @Description   This function writes a send data initialization word into 
//                the transmit buffer register.
//                
//                Note: 
//                In a multiprocessor system the master with this function 
//                has the possibility to send data to the selected slave. To 
//                achieve this, the 9th bit must set on zero.
//
//----------------------------------------------------------------------------
// @Returnvalue   None
//
//----------------------------------------------------------------------------
// @Parameters    uwData: 
//                Data to be send
//
//----------------------------------------------------------------------------
// @Date          19.12.2003
//
//****************************************************************************

// USER CODE BEGIN (SendData,1)

// USER CODE END

void ASC0_vSendData(uword uwData)
{
  ASC0_TBIC_IR = 0;        //  reset transmit buffer interrupt request 
  ASC0_TBUF    = uwData;   //  load transmit buffer register

} //  End of function ASC0_vSendData


//****************************************************************************
// @Function      uword ASC0_uwGetData(void) 
//
//----------------------------------------------------------------------------
// @Description   This function reads out the content of the receive buffer 
//                register which contains the received data.
//
//----------------------------------------------------------------------------
// @Returnvalue   data that has been received
//
//----------------------------------------------------------------------------
// @Parameters    None
//
//----------------------------------------------------------------------------
// @Date          19.12.2003
//
//****************************************************************************

// USER CODE BEGIN (GetData,1)

// USER CODE END

uword ASC0_uwGetData(void)
{
  ASC0_RIC_IR = 0;       // reset receive interrupt request
  return(ASC0_RBUF);     // return receive buffer register

} //  End of function ASC0_uwGetData




// USER CODE BEGIN (ASC0_General,10)

// USER CODE END

⌨️ 快捷键说明

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