Skip to main content
lorenzo meneghello
Associate III
March 5, 2017
Question

Problem on USART

  • March 5, 2017
  • 20 replies
  • 3144 views
Posted on March 05, 2017 at 19:53

Hi, 

I'm working on STM32F091 MCU fora the first time and I'm trying to test the USART1 on PF0,1. I have just wrote the code and it works well, but now I can't receive the RXNE interrupt.. the tx line works normally.. if I try to set the port as an input I see the correct logic level on pin so the port works, it seems that the shift register of USART NOT WORK. Any idea?

Thanks.

lorenzo.

    This topic has been closed for replies.

    20 replies

    Tesla DeLorean
    Guru
    March 5, 2017
    Posted on March 05, 2017 at 20:35

    >>Any idea?

    Show the code, and indicate what model of STM32F091 specifically you are using, and that has USART1 on PF0 and PF1

    http://www.st.com/content/ccc/resource/technical/document/datasheet/95/3c/2e/5b/21/09/45/a6/DM00115237.pdf/files/DM00115237.pdf/jcr:content/translations/en.DM00115237.pdf

     

    Both TX, and RX pins should be configured in AF mode, and muxed correctly.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Selso LIBERADO
    Associate II
    March 6, 2017
    Posted on March 06, 2017 at 13:57

    Hello !

    did you actually use the STMCube firmware, did you you STMCubeMX to configure your pins ?

    did you check that the IRQ is enabled ?

    It's actually hard to give an answer without any code information ?

    lorenzo meneghello
    Associate III
    March 7, 2017
    Posted on March 07, 2017 at 21:34

    Thanks for the reply! 

    The code is very simple just configure the pin and the speed like ST example, the code works. I've connected the STM with the Max232 but is supplied with 5V.. it maybe the problem? 

    Tesla DeLorean
    Guru
    March 7, 2017
    Posted on March 07, 2017 at 22:16

    A MAX3232 would be more appropriate. I suspect most pins are 5V tolerant at this point, but check the Data Sheet.

    What part / board are you using. Give all the digits of the part number so I can at least correlate your PF0 and PF1 pining to some part supporting the USART there.

    >>

    The code is very simple just configure the pin and the speed like ST example, the code works.

    Let me judge the validity of the code, cause you're complaining it is not working, so something is wrong with your logic at some level.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    lorenzo meneghello
    Associate III
    March 8, 2017
    Posted on March 08, 2017 at 09:21

    I'm using the STM32F091RBT6 on my board, and the USART1 port are PA9&PA10.

    This is the code:

    void UsartInit (void) {

       RCC->APB2ENR |= RCC_APB2ENR_USART1EN; // enable clock for Alternate Function

       GPIOA->MODER |= 0x280000;

       GPIOA->AFR[1] |= 0x110;

       GPIOA->OSPEEDR |= 0x300000; //PA10

       USART1->BRR = 0x1388; // set baudrate 9600BAUD 

       USART1->CR1 |= (USART_CR1_RE | USART_CR1_TE);

       NVIC_EnableIRQ(USART1_IRQn);

       USART1->CR1 |= USART_CR1_UE; // USART enable

       USART1->CR1 |= USART_CR1_RXNEIE;   

         }

    The TX line works and also the RX line has worked but now it van't receive the RXNEIE interrupt.. if I enable the IDLE line interrupt I receive the interrupt so the interrupt configuration works.

    Thanks. 

    Lorenzo.

    lorenzo meneghello
    Associate III
    March 14, 2017
    Posted on March 14, 2017 at 12:00

    Any other idea? Thanks.

    Tesla DeLorean
    Guru
    March 14, 2017
    Posted on March 14, 2017 at 13:27

    Not really much to work with here, kind of hard to debug through the keyhole.

    Perhaps present some diagnostic/analysis you've done, like plots from a scope or logic analyzer. Schematic for the circuit.

    Perhaps you have a colleague who can review things with you or try other known working code/hardware.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    lorenzo meneghello
    Associate III
    March 22, 2017
    Posted on March 22, 2017 at 17:05

    Hi all,

    2 weeks that I'm trying to comunicate with this UART.. Now I've a new news! If found that if I disable the TE bit I can receive from the PC... Any idea?

    Thanks.

    Tesla DeLorean
    Guru
    March 23, 2017
    Posted on March 23, 2017 at 01:26

    Perhaps there is some language difficultly here, I've asked for specific things, I've provided some example code, and you're still playing this 'guess what's wrong game'.

    Present the problem so someone on the other side of the Atlantic can review the code and hardware you are working with. If you spend 20-30 mins doing this you might be able to see the problem for yourself.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    lorenzo meneghello
    Associate III
    March 23, 2017
    Posted on March 23, 2017 at 09:55

    Ok I've create a folder with the code and schematic.

    Thanks!

    ________________

    Attachments :

    USART problem.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HylC&d=%2Fa%2F0X0000000bCA%2FEi_wXIZsxzlAfBshclBi0AQIvCRpYQKln1WXD8PgDEU&asPdf=false
    lorenzo meneghello
    Associate III
    March 24, 2017
    Posted on March 24, 2017 at 15:46

    Ok don't know why but the solution is to use the another USART.... I've used the USART3 and now it works perfectly! setted on the same manner.

    Marek Bílý
    Associate
    June 15, 2017
    Posted on June 15, 2017 at 21:33

    You maybe use registry view, which clear status registry flag.