cancel
Showing results for 
Search instead for 
Did you mean: 

USART1 Very Low Output Signal

dclark9
Associate II
Posted on June 13, 2012 at 12:15

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 STM32F107VCT6

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

}
6 REPLIES 6
frankmeyer9
Associate II
Posted on June 13, 2012 at 13:14

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

Posted on June 13, 2012 at 14:07

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
dclark9
Associate II
Posted on June 13, 2012 at 14:44

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,

Dave

dclark9
Associate II
Posted on June 13, 2012 at 14:44

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,

Dave

Posted on June 13, 2012 at 15:24

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
dclark9
Associate II
Posted on June 25, 2012 at 15:24

Got this working in the end - not sure exactly what was wrong with it, but thankyou so much for your help once again.