在线时间445 小时
UID2011467
注册时间2013-5-17
NXP金币0
该用户从未签到
金牌会员
 
- 积分
- 5781
- 最后登录
- 1970-1-1
|
发表于 2015-4-10 16:44:43
|
显示全部楼层
本帖最后由 FSL_TICS_ZP 于 2015-4-10 16:54 编辑
楼主,你原来的代码应该是可以用的,我在这个基础简化一下,是可以收到数据的,我的代码和完整的工程如下
- /**
- \mainpage
- \n Copyright (c) 2011 Freescale
- \n Freescale Confidential Proprietary
- \brief
- \author Freescale Semiconductor
- \author
- \version m.n
- \date Sep 14, 2011
-
- Put here all the information needed of the Project. Basic configuration as well as information on
- the project definition will be very useful
- */
- /****************************************************************************************************/
- /* */
- /* All software, source code, included documentation, and any implied know-how are property of */
- /* Freescale Semiconductor and therefore considered CONFIDENTIAL INFORMATION. */
- /* This confidential information is disclosed FOR DEMONSTRATION PURPOSES ONLY. */
- /* */
- /* All Confidential Information remains the property of Freescale Semiconductor and will not be */
- /* copied or reproduced without the express written permission of the Discloser, except for copies */
- /* that are absolutely necessary in order to fulfill the Purpose. */
- /* */
- /* Services performed by FREESCALE in this matter are performed AS IS and without any warranty. */
- /* CUSTOMER retains the final decision relative to the total design and functionality of the end */
- /* product. */
- /* FREESCALE neither guarantees nor will be held liable by CUSTOMER for the success of this project.*/
- /* */
- /* FREESCALE disclaims all warranties, express, implied or statutory including, but not limited to, */
- /* implied warranty of merchantability or fitness for a particular purpose on any hardware, */
- /* software ore advise supplied to the project by FREESCALE, and or any product resulting from */
- /* FREESCALE services. */
- /* In no event shall FREESCALE be liable for incidental or consequential damages arising out of */
- /* this agreement. CUSTOMER agrees to hold FREESCALE harmless against any and all claims demands or */
- /* actions by anyone on account of any damage,or injury, whether commercial, contractual, or */
- /* tortuous, rising directly or indirectly as a result of the advise or assistance supplied CUSTOMER*/
- /* in connectionwith product, services or goods supplied under this Agreement. */
- /* */
- /****************************************************************************************************/
- /*****************************************************************************************************
- * Include files
- *****************************************************************************************************/
- #include "common.h"
- /*****************************************************************************************************
- * Declaration of module wide FUNCTIONs - NOT for use in other modules
- *****************************************************************************************************/
- /*****************************************************************************************************
- * Definition of module wide MACROs / #DEFINE-CONSTANTs - NOT for use in other modules
- *****************************************************************************************************/
- /*****************************************************************************************************
- * Declaration of module wide TYPEs - NOT for use in other modules
- *****************************************************************************************************/
- /*****************************************************************************************************
- * Definition of module wide VARIABLEs - NOT for use in other modules
- *****************************************************************************************************/
- /*****************************************************************************************************
- * Definition of module wide (CONST-) CONSTANTs - NOT for use in other modules
- *****************************************************************************************************/
- /*****************************************************************************************************
- * Code of project wide FUNCTIONS
- *****************************************************************************************************/
- #include "common.h"
- #include "isr.h"
- void UART_RIE_Enable(void);
- void UART_Isr(void);
- extern uint32 gu32UARTStatus;
- uint32 gu32UARTStatus;
- uint32 gu32UATRxCounter = 0;
- uint8 * gpu8UARTTx;
- uint8 * gpu8UARTRx;
- uint32 gu32TxDataSize=0x10;
- uint32 gu32RxCounter = 0x10;
- typedef enum
- {
- TX_COMPLETE = 0,
- RX_DATA,
- }eUARTStatus;
- #define RX_COMPLETE (gu32UARTStatus & (1 << UART_S1_RDRF_SHIFT))
- #define TX_END (gu32UARTStatus & (1 << UART_S1_TC_SHIFT))
- /**
- * \brief main
- * \author
- * \param none
- * \return none
- * \todo
- * \warning
- */
- int main (void)
- {
- char ch;
- #ifdef KEIL
- start();
- #endif
-
- //printf("\nRunning the 'hello world' project for the K21 50 MHz family\n");
- EnableInterrupts;
- enable_irq(35);
- UART_RIE_Enable();
- while(1)
- {
- // ch = getchar();
- // putchar(ch);
- //ch = in_char();
- //out_char(ch);
- }
- }
- /********************************************************************/
- void UART_RIE_Enable(void)
- {
-
- UART2_C2|= UART_C2_RIE_MASK | UART_C2_TCIE_MASK;
-
-
- }
- void UART_Isr(void)
- {
- uint8 u8temp = UART2_S1;
- uint8 rev;
- if(UART2_S1 & UART_S1_RDRF_MASK)
- {
- rev = UART2_D;
-
- //gpu8UARTRx++;
- gu32RxCounter--;
- if(!gu32RxCounter)
- {
- gu32UARTStatus |= (1 << RX_DATA);
- out_char('Y');
- }
- }
- if(UART2_S1 & UART_S1_TC_MASK)
- {
- if(gu32TxDataSize)
- {
- UART2_D = 0x32;
- gu32TxDataSize--;
- }
- else
- {
- UART2_C2 &= ~UART_C2_TCIE_MASK;
- gu32UARTStatus |= (1 << TX_COMPLETE);
- }
- }
- }
复制代码
TWR-K21D50M Sample Code.zip
(9.34 MB, 下载次数: 13)
|
|