Skip to main content
anil23
Associate III
September 28, 2007
Question

UART receive DMA with ISR

  • September 28, 2007
  • 15 replies
  • 2850 views
Posted on September 28, 2007 at 11:05

UART receive DMA with ISR

This topic has been closed for replies.

15 replies

nanuradha
Associate III
May 17, 2011
Posted on May 17, 2011 at 09:34

Hi Mirou,

i have modified my code according to u'r sugession. but no luck.

i got some junk values on hyper terminal.

is there any settings required for Hyperterminal?

have a glance of my code.

/******************** (C) COPYRIGHT 2006 STMicroelectronics ********************

* File Name : main.c

* Author : MCD Application Team

* Date First Issued : 05/18/2006 : Version 1.0

* Description : Main program body

********************************************************************************

* History:

* 05/24/2006 : Version 1.1

* 05/18/2006 : Version 1.0

********************************************************************************

* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS

* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.

* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,

* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE

* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING

* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

*******************************************************************************/

/* Includes ---------------*/

#include ''91x_lib.h''

/* Private typedef --------*/

/* Private define ---------*/

#define TxBufferSize (countof(TxBuffer) - 1)

#define RxBufferSize 0xFF

/* Private macro ----------*/

#define countof(a) (sizeof(a) / sizeof(*(a)))

/* Private variables ------*/

UART_InitTypeDef UART_InitStructure;

u8 TxBuffer[] = ''UART Example: UART - Hyperterminal\n\r'';

u8 RxBuffer[RxBufferSize];

u8 NbrOfDataToTransfer = TxBufferSize;

u8 TxCounter = 0;

u8 RxCounter = 0;

// ****************************************************************

// Phase Lock Loop (PLL) setting

// ****************************************************************

#define PLL_M 25 // M (1 <= M <= 255) value for phase lock loop

#define PLL_N 192 // N (1 <= N <= 255) value for phase lock loop

#define PLL_P 3 // P (1 <= P <= 5) value for phase lock loop

// ****************************************************************

// clocks divisor setting

// ****************************************************************

#define RCLK_Divisor SCU_RCLK_Div1 // Reference clock divisor

#define HCLK_Divisor SCU_HCLK_Div1 // ARM high speed bus divisor

#define PCLK_Divisor SCU_PCLK_Div2 // ARM Peripheral bus divisor

#define FMICLK_Divisor SCU_FMICLK_Div1 // FMI divisor

/* Private function prototypes -------------*/

void SCU_Configuration(void);

void GPIO_Configuration(void);

/* Private functions ------*/

/*******************************************************************************

* Function Name : main

* Description : Main program

* Input : None

* Output : None

* Return : None

*******************************************************************************/

int main()

{

u8 i;

#ifdef DEBUG

debug();

#endif

SCU_PLLFactorsConfig(192, 25, 3);

SCU_PLLCmd(ENABLE);

SCU_RCLKDivisorConfig(SCU_RCLK_Div1);

SCU_HCLKDivisorConfig(SCU_HCLK_Div1);

SCU_PCLKDivisorConfig(SCU_PCLK_Div2);

SCU_FMICLKDivisorConfig(SCU_FMICLK_Div1);

SCU_MCLKSourceConfig(SCU_MCLK_PLL);

/* Configure the system clocks */

SCU_Configuration();

/* Configure the GPIO ports */

GPIO_Configuration();

UART_InitStructure.UART_WordLength = UART_WordLength_8D;

UART_InitStructure.UART_StopBits = UART_StopBits_1;

UART_InitStructure.UART_Parity = UART_Parity_No ;

UART_InitStructure.UART_BaudRate = 115200;

UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;

UART_InitStructure.UART_Mode = UART_Mode_Tx;//_Rx;

UART_InitStructure.UART_FIFO = UART_FIFO_Enable;

UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */

UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */

UART_DeInit(UART1);

UART_Init(UART1, &UART_InitStructure);

/* Enable the UART1 */

UART_Cmd(UART1, ENABLE);

UART_LoopBackConfig(UART1, DISABLE);

TxCounter = 0;

UART_SendData(UART1, 0x00);

//while(1){

while(NbrOfDataToTransfer--)

{

UART_SendData(UART1, TxBuffer[TxCounter++]);

while(UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) != RESET);

}

for(i=0;i

NbrOfDataToTransfer = TxBufferSize;

TxCounter = 0;

//}

//do

//{

//if((UART_GetFlagStatus(UART1, UART_FLAG_RxFIFOEmpty) != SET)&&(RxCounter < RxBufferSize))

//{

//RxBuffer[RxCounter] = UART1->DR;

//UART_SendData(UART1, RxBuffer[RxCounter++]);

//}

//

//}while((RxBuffer[RxCounter - 1] != '\r')&&(RxCounter != RxBufferSize));

while (1);

}

/*******************************************************************************

* Function Name : SCU_Configuration

* Description : Configures the system clocks.

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void SCU_Configuration(void)

{

/* Enable the UART1 Clock */

SCU_APBPeriphClockConfig(__UART1, ENABLE);

SCU_APBPeriphClockConfig(__GPIO3, ENABLE);

}

/*******************************************************************************

* Function Name : GPIO_Configuration

* Description : Configures the different GPIO ports.

* Input : None

* Output : None

* Return : None

*******************************************************************************/

void GPIO_Configuration(void)

{

GPIO_InitTypeDef GPIO_InitStructure;

//GPIO_DeInit(GPIO3);

///*Gonfigure UART1_Rx pin GPIO3.2*/

//GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;

//GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;

//GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;

//GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;

//GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ;

//GPIO_Init (GPIO3, &GPIO_InitStructure);

GPIO_DeInit(GPIO3);

/*Gonfigure UART1_Tx pin GPIO3.3*/

GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;

GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;

GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;

GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2 ;

GPIO_Init (GPIO3, &GPIO_InitStructure);

}

/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/

thanks

raj.

nanuradha
Associate III
May 17, 2011
Posted on May 17, 2011 at 09:34

hai mirou,

we are using MCB-STR9 Vers.3 Evaluation Board.

On which board u r tested my code?

according to program i think so there is no mistake.

what are the other areas which may cause problem?

please send me the UART working Example project file.

thanks & Regards

Raj.

nanuradha
Associate III
May 17, 2011
Posted on May 17, 2011 at 09:34

hai mirou,

i have used u'r hyper terminal file but it is also same as my file.

thank u to conformed that my program is working.

i have tried it in some other system (Hyperterminal), but no use.

i could not find the mistake where actual problem is?

please send me the complete project so that i will find my problem whether it is in Startup code or some where else. its better for me to have a working program.

Thanks for u'r constant help.

regards

raj.

[ This message was edited by: anuradha on 28-12-2006 06:24 ]

[ This message was edited by: anuradha on 28-12-2006 08:10 ]

amira1
Associate
May 17, 2011
Posted on May 17, 2011 at 09:34

Hi anuradha,

I tested your code with MCB-STR9 board and it works well for me. May be you configured wrong the hyperteminal utility.

You find attached the hyperteminal configuration that I've used.

Best regards

mirou

nanuradha
Associate III
May 17, 2011
Posted on May 17, 2011 at 09:34

hai Zouh,

yes we are using crossover cable (2-3, 3-2, 5-5 of db connector).

we are using Keil uVision3.03a software for Debug.

did u check my code?

regards

raj.