2012-06-13 03:15 AM
Hi,
I am doing what on paper should be one of the simplest tasks possible with a USART - namely configuring it and then getting it to output a pattern using USART_SendData();When I send this command it is definitely doing something but I get a tiny drop of less than a volt that looks like it might not even be a signal. Does anyone have any ideas why this is happenning?Am using an STM32F107VCT6Init code is as follows :-RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE); /* Configure HDSR TX as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); 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_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Tx; USART_Init(USART1, &USART_InitStructure); /* Enable the HDSRUSART */ USART_Cmd(USART1, ENABLE) ;while(1){USART_SendData(USART1 , 0x55);}2012-06-13 04:14 AM
On which hardware ?
Are there possibly some shorts on these pins ? What do you see if you remove any load from the pins (if that's possible) ?2012-06-13 05:07 AM
PA9 is a CMOS level pin, do not connect it to an RS232 level pin. Make sure it is connected to a receive pin at the destination, and not fighting with another output pin.
The USART_SendData() needs to be called when the TXE status bit is set, and not just repeatedly.2012-06-13 05:44 AM
Hi Clive,
Thanks for your reply.I have tried checking the TXE flag (which always seems to be set) and this still does not make any difference. In terms of connection, I have the the pin simply connected from an evaluation board to an oscilloscope.One thought I did have is that with this being a USART is it expecting a clock on PA8 as I have tried this code on UART5 with absolutely no problems at all - so is there something different between the UART and USARTs that I am missing.Thanks,Dave2012-06-13 05:44 AM
Hi Clive,
Thanks for your reply.I have tried checking the TXE flag (which always seems to be set) and this still does not make any difference. In terms of connection, I have the the pin simply connected from an evaluation board to an oscilloscope.One thought I did have is that with this being a USART is it expecting a clock on PA8 as I have tried this code on UART5 with absolutely no problems at all - so is there something different between the UART and USARTs that I am missing.Thanks,Dave2012-06-13 06:24 AM
Hi Dave,
You shouldn't need an external clock as you're not setting it up in synchronous mode, the initialization looks to be fine, I normally enable both Tx/Rx. Generally if the voltages look wrong, you either have a short to another pin, conflicts with something else on the board, or you are looking at the wrong pin. You could try configuring the pin as a GPIO and drive it high and low, see if that works.2012-06-25 06:24 AM
Got this working in the end - not sure exactly what was wrong with it, but thankyou so much for your help once again.