cancel
Showing results for 
Search instead for 
Did you mean: 

Usart4 no TX

stenasc
Senior
Posted on May 15, 2017 at 10:40

Hi Forum,

I'm using the stm32f091RCt6, (LQFP64) to set up USART4

Kind Regards

Bob

  USART_InitTypeDef USART_InitStructure;

  GPIO_InitTypeDef GPIO_InitStructure;

  NVIC_InitTypeDef NVIC_InitStructure;

  // Enable GPIOC clock

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);

 

  // Enable USART3 APB clock

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART4, ENABLE);

    

 

  // Connect pin to Periph

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_0);   //  USART4 TX

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_0);   //  USART4 RX

 

  // Configure pins as AF pushpull

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;

  GPIO_Init(GPIOC, &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_Rx | USART_Mode_Tx;

  USART_Init(USART4, &USART_InitStructure);

    

  USART_Cmd(USART4, ENABLE);

      

//  Enable the COM4 Receive interrupt: this interrupt is generated when the

//  COM4 receive data register is not empty

  USART_ITConfig(USART4, USART_IT_RXNE, ENABLE);

  // USART4 IRQ Channel configuration

  NVIC_InitStructure.NVIC_IRQChannel = USART3_8_IRQn;   

  NVIC_InitStructure.NVIC_IRQChannelPriority = 1;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

Although I can receive data I cannot get any TX at all.  I have usart1 and usart2 working fine. not sure what is is. I've buzzed out all the board connections and they are fine. Looking at the clock tree on page16 of the datasheet, I notice PCLK only goes to usart1, usart2 and usart3. Does usart4 need some aqlternative form of clocking? The datasheet really doesnt say to much about usarts4 to 8 and there are no app notes out there to refer to so i'm stuck at this point.

Thanks for any help.

Regards Bob

35 REPLIES 35
Posted on May 19, 2017 at 00:15

Even with the DI pin on the ST485 snipped, the TX does not work and  because swapping TX to PC11 works it looks as if there is an issue with PC10. I can't think of anything else.

Bob

Posted on May 19, 2017 at 01:20

http://www.st.com/en/evaluation-tools/nucleo-f091rc.html

 
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
John F.
Senior
Posted on May 19, 2017 at 08:54

'swapping TX to PC11 works' doesn't make sense. PC11 only offers USART4_RX and no TX from any USART. Are you sure you're identifying the pins correctly?

John F.
Senior
Posted on May 19, 2017 at 11:48

'Why is it the when I use the following command :

USART_SWAPPinCmd function I can see data on PC11?

'

Why indeed! I was unaware of this feature and had used the STM32Cube graphical view of the part to look at the available pin functions. With the

/external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fen%2Fevaluation-tools%2Fnucleo-f091rc.html

available from Mouser (UK) for

£8.71,you might just buy one and see if it has the same problem ... but first, I'd do as Jan W. suggests and check the bits in all those USART configuration.

Are you using mbed?

Posted on May 19, 2017 at 10:00

I agree.

As said before, on a custom board prototype, you can take nothing for granted. Layout included.

You could desolder the MCU pin and lift it up slightly, to exclude layout/soldering issues.

Posted on May 19, 2017 at 10:34

Hi John

Why is it the when I use the following command : 

USART_SWAPPinCmd function I can see data on PC11?

Posted on May 19, 2017 at 10:40

Hi Clive,

No problem, I'l buy it, even a couple, just to figure this out.

Posted on May 19, 2017 at 11:00

''swapping TX to PC11 works'' doesn't make sense. PC11 only offers USART4_RX and no TX from any USART.

Why is it the when I use the following command : 

USART_SWAPPinCmd function I can see data on PC11?

Huh, I've never seen such a weird feature on an USART... funny but, honestly, I can't think of a scenario where this could be really useful.

0690X0000060736QAA.png

To the original problem: read out the relevant GPIO registers content if it's set properly.

JW

Posted on May 19, 2017 at 11:37

Huh, I've never seen such a weird feature on an USART...

I came across it some years ago with another F0 device, so it is not really new for ST devices.

... funny but, honestly, I can't think of a scenario where this could be really useful.

+1

This issue is perhaps a candidate for the errata.

I would primarily test with all external components disconnected (including PCB traces), and on multiple boards.

Posted on May 19, 2017 at 12:35

 I did mention to Clive earlier in the thread that I would buy one of these NUCLEO boards to try out. I've seen the same issue on a number of boards. The 485 data input pin has been disconnected. Configured as an ordinary GPIO, the line toggles as required, so there is no short to GND. There is no short to adjacent pins so will have to get board xrayed, but I suspect nothing will show.

Bob