cancel
Showing results for 
Search instead for 
Did you mean: 

UART communication problem

thiagodaipra
Associate II
Posted on January 30, 2009 at 12:55

UART communication problem

2 REPLIES 2
thiagodaipra
Associate II
Posted on May 17, 2011 at 09:57

Hi

I'm trying to do use serial port with hyperterminal to be able to debug more complex apps.I already searched other similar topics but they didn't solve my problem.

So, after the configuration of Uart and hyperterminal, I can send data from the pc(which is shown in the leds of the eval board), but the pc doesn't receive data(nothing is shown in the hyperterminal)

I'm sending the uart config and the send/receive part of the code...

I'm using Reva 2.10 eval board with str912f

=======================//=================================

//Send - Receive

while(NbrOfDataToTransfer--)

{

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

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

}

GPIO_Write(GPIO6,0x55);

/* Receive a string (Max RxBufferSize bytes) from the Hyperterminal ended by '\r' (Enter key) */

do

{

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

{

RxBuffer[RxCounter] = UART_ReceiveData(UART0);

UART_SendData(UART0, RxBuffer[RxCounter++]);

GPIO_Write(GPIO6,RxBuffer[RxCounter - 1]);

}

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

GPIO_Write(GPIO6, 0xAA);

while (1);

===============================//=======================================

void UART0_Configuration(void)

{

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 = 115000;

UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;

UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx;

UART_InitStructure.UART_FIFO = UART_FIFO_Enable;//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(UART0);

UART_Init(UART0, &UART_InitStructure);

/* Enable the UART0 */

UART_Cmd(UART0, ENABLE);

}

=================================//==================================

void GPIO_Configuration(void)

{

/*GPIO0 Deinitialization*/

GPIO_DeInit(GPIO6);

/*GPIO0 configuration (leds)*/

GPIO_StructInit(&GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;

GPIO_Init(GPIO6, &GPIO_InitStructure);

GPIO_DeInit(GPIO3);

//Rx = pin 3.0

GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;

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);

// Tx = pin 3.1

GPIO_StructInit(&GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;

GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1;

GPIO_Init(GPIO3, &GPIO_InitStructure);

}

thiagodaipra
Associate II
Posted on May 17, 2011 at 09:57

already solved it...

simple mistake at the Tx pin configuration, that I didn't notice.

it should be OutputAlt2 not OutputAlt1