cancel
Showing results for 
Search instead for 
Did you mean: 

STM32-VLDiscovery UART between Eval & PC Problem

bandido1
Associate II
Posted on December 19, 2011 at 17:20

Hi

I trying to access UART connection between eval board and pc. I am using uart 1 on PA9 and PA To change the signals i am using a MAX From the eval board to the pc the signals are correct, but bei receiving the signals interrupt driven the signals are defect. The interrupt gets invoke, but the characters are totally wrong. Has anyone any idea?

//set up usart 
GPIO_InitTypeDef GPIO_InitStructure; 
USART_InitTypeDef USART_InitStructure; 
USART_ClockInitTypeDef USART_ClockInitStructure; 
//set up uart************************************************************************************** 
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE); 
initInterrupt(); 
//Set USART1 Tx (PA.09) as AF push-pull 
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 
GPIO_Init(GPIOA, &GPIO_InitStructure); 
//Set USART1 Rx (PA.10) as input floating 
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 
GPIO_Init(GPIOA, &GPIO_InitStructure); 
USART_ClockStructInit(&USART_ClockInitStructure); 
USART_ClockInit(USART1, &USART_ClockInitStructure); 
USART_InitStructure.USART_BaudRate = 9600; 
USART_InitStructure.USART_WordLength = USART_WordLength_8b; 
USART_InitStructure.USART_StopBits = USART_StopBits_1; 
USART_InitStructure.USART_Parity = USART_Parity_No; 
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; 
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 
//Write USART1 parameters 
USART_Init(USART1, &USART_InitStructure); 
//Enables interrupt 
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); 
//Enable USART1 
USART_Cmd(USART1, ENABLE); 
for(i = 0; i < 100; i ++) 
{ 
USART_SendData(USART1, 0x54); 
while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) 
{ 
} 
} 
//Interrupt routine 
void USART1_IRQHandler(void) 
{ 
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) 
{ 
/* Read one byte from the receive data register */ 
uint8_t test = 0; 
PCOutSPIINBuffer[PCOutSPIINBufferPointer++] = USART_ReceiveData(USART1); 
test = PCOutSPIINBuffer[PCOutSPIINBufferPointer - 1]; 
if(PCOutSPIINBufferPointer == NbrOfDataToRead) 
{ 
//todo error Buffer overflow 
PCOutSPIINBufferPointer = 0; 
USART_ITConfig(USART1, USART_IT_RXNE, DISABLE); 
} 
}

#stmvl-discovery-usart
2 REPLIES 2
Posted on December 20, 2011 at 21:11

Some examples of ''totally wrong'' would be helpful.
 
 I think you need to focus on the hardware side, and do some basic diagnostics. Check the bit timing of the received signal to confirm the baud rate is as expected. Look at the bit data and confirm the signal has the expected properties (levels/content).
 
 Check if the USART status register is indicating any failure conditions.
 
 The STM32VL-Discovery board can be interfaced quite easily with boards like the DLP-TXRX-G http://www.dlpdesign.com/usb/txrx.shtml
 
 Terminal programs like TeraTerm or RealTerm are also recommended.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bandido1
Associate II
Posted on December 21, 2011 at 08:00

Hi Clive1

Thank you for answering.

Totally wron means, that i receive only 156 instead of a 'H' which is a 48.

I checked the signal with a scope on the input and see its o.k.

On the PC side i'm using hyperterminal. The Signal is like usually

low active. I had checked the status register by calling ''USART_getITStatus(),

but i'm not certain, if this way is correct.