Skip to main content
stenasc
Associate III
May 15, 2017
Solved

Usart4 no TX

  • May 15, 2017
  • 35 replies
  • 4698 views
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

    This topic has been closed for replies.
    Best answer by stenasc
    Posted on May 29, 2017 at 22:51

    Hi Forum,

    Finally found the issue. It turned out to be a manufacturing problem. A solder ball short was present on some boards and not on others between a via under the ST part and pin. It looks as if there wasn't enough clearance between them and occurred during solder reflow. If the board was shaken, then it sometimes moved, and everything looked good.

    So many thanks to everyone who replied. All of you were pointing in the correct direction. The Nucleo board proved that the TX pin worked so that gave me a good baseline so start with. I also understand now why swapping the pins allowed the TX to work. Many thanks to you all.

    Kind Regards

    Bob.

    35 replies

    Tesla DeLorean
    Guru
    May 15, 2017
    Posted on May 15, 2017 at 16:20

    Check VDDIO2 pin

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    May 15, 2017
    Posted on May 15, 2017 at 17:39

    Don't enable the IRQ, write a simple demo that tightly loops outputting a 'U' character. Double check the board, pin connectivity, etc. Not familiar with the board in question.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    ST Technical Moderator
    May 15, 2017
    Posted on May 15, 2017 at 16:45

    Check also your reference manual, it may help you on your USART configuration.

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Tesla DeLorean
    Guru
    May 15, 2017
    Posted on May 15, 2017 at 17:38

    Not sure that's terribly helpful, on the surface of things the code doesn't appear unreasonable, is there some specific insight you can share?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    stenasc
    stenascAuthor
    Associate III
    May 15, 2017
    Posted on May 15, 2017 at 23:25

    VDDIO is at 3.3V. The following is my test code. I scope PC10 but see absolutely no activity at all. Changed boards but made no difference.

       send_test_string('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');

    int send_test_string(unsigned char * byte)

    {    

      for (;*byte;++byte)

         {            

          send_char (*byte);

         }            

    return 1;

     }

    void   send_char (uint8_t ch)

    {

      USART_SendData(USART4, (uint8_t) ch);

      /* Loop until the end of transmission */

      while (USART_GetFlagStatus(USART4, USART_FLAG_TC) == RESET)    

      {}       

    }
    Tesla DeLorean
    Guru
    May 16, 2017
    Posted on May 16, 2017 at 00:27

    Perhaps there is a design issue, I have neither the board nor the chip.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    John F.
    Associate III
    May 17, 2017
    Posted on May 17, 2017 at 08:30

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

    stenasc
    stenascAuthor
    Associate III
    May 17, 2017
    Posted on May 17, 2017 at 16:05

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

    stenasc
    stenascAuthor
    Associate III
    May 18, 2017
    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. 

    stenasc
    stenascAuthor
    Associate III
    May 19, 2017
    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

    Tesla DeLorean
    Guru
    May 19, 2017
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    John F.
    Associate III
    May 19, 2017
    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?

    AvaTar
    Senior III
    May 19, 2017
    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.

    John F.
    Associate III
    May 19, 2017
    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?

    stenasc
    stenascAuthor
    Associate III
    May 19, 2017
    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 

    stenasc
    stenascAuthor
    Associate III
    May 22, 2017
    Posted on May 22, 2017 at 09:43

    OK, nothing showed up on boards, so going to order a NUCLEO-F091RC kit today. Not sure what that is going to tell me, if it is my code setup that's at fault but at £8.71 each, its not going to really break the budget.

    Bob

    Tesla DeLorean
    Guru
    May 22, 2017
    Posted on May 22, 2017 at 14:05

    It will tell you whose side of the fence the problem is. If it is ST's then they will have a specific target board from which to replicate the issue, and kills arguments about implementation. 

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    stenasc
    stenascAuthor
    Associate III
    May 25, 2017
    Posted on May 25, 2017 at 14:04

    I received the Nucleo board, but it now looks as if I need a different programmer. I have an ST-Link V2 programmer which I can either use with St-Link software or Uvision (see link). As I don't have a header to fit the Nucleo boards, can I use flying leads from this programmer or do I need to order a new type. Also tried mbed, but I'm really not interested in this. I currently use Uvision to develop code and this serves me well, so I don't particularly want to change.  

    Can you recommend a programmer that will do the job.

    Thank you

    Bob

    http://uk.rs-online.com/web/p/products/7141701/?grossPrice=Y&cm_mmc=UK-PLA-_-google-_-PLA_UK_EN_Semiconductors-_-Semiconductor_Development_Kits&mkwid=sOE1F4w4l_dc|pcrid|88057061283|pkw||pmt||prd|7141701&gclid=COm0gsn-itQCFdKEswod_ZcNLw