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 16, 2017 at 11:05

Sounds all reasonable to me as well.

Have you ruled out a short to a neighboring pin ?

Or something else connected to it ?

Posted on May 16, 2017 at 14:02

I checked for a short and it looks OK. The TX pin from the micro is connected to DI on a ST485 part. I wondering if the ST485 was loading the TX pin, but the datasheet only specs a few microamp.

Posted on May 16, 2017 at 14:26

If you deal with a custom board or prototype, the schematics/layout could be wrong, or the RS485 driver populated wrong (reverse). I would check without.

Have you considered/connected the DE pin (driver enable) of the ST485 ?

Posted on May 16, 2017 at 15:17

I drive DE high during TX. I see it pulsing high on ST485 pin, but the uart tx pin, connected to DI of 485 always.remains low. I'll snip the DI pin input on the ST485 and see what happens 

Posted on May 16, 2017 at 15:58

I hope you have checked for a proper connection as well (TX --> DI).

With a prototype board, take nothing for granted. Hardware guys can make mistakes, too ...

Posted on May 16, 2017 at 17:40

The code looks to be Ok, the chip docs suggest USART4 is available, AF mapping looks right, and you have the RX working. Not a chip I'm using, no mag ic wand I can wave from this end.

Stupid forum! Why is this going to moderation!

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 17, 2017 at 08:30

The ST485 requires VCC = 5 V ± 5 %. Are you powering it from 5V?

stenasc
Senior
Posted on May 17, 2017 at 16:05

Will get back to this later today and let you know.

Posted on May 17, 2017 at 16:35

>>Stupid forum! Why is this going to moderation!

Apparently word that rhymes with tragic..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stenasc
Senior
Posted on May 18, 2017 at 09:26

The 485 pin is powered from 5V. I swapped the usart pins using the 

USART_SWAPPinCmd function and TX is now looking fine. Thought the orientation of the ST485 part might be incorrect, but it is fine. Same problem on another board as well, so going to remove 485 parts to see what uart TX and RX signals look like in their normal configuration.