cancel
Showing results for 
Search instead for 
Did you mean: 

UART Communication

harry123
Senior

Hi

  • I am trying to commuicate between two boards through UART.
  • One board is nucleof4 and other board is a processor.
  • Im sending a data from nucleo to other board(where data gets displayed) through HAL_UART_Transmit(&huart1,(uint8_t*)"Connect",sizeof("Connect"),100);
  • The problem that Im facing is data is getting  displayed on pressing reset button on nucleo several times.
  • The communication is not smooth
  • J25 connector as shown in image is where im interfacing my nucleo f446re with processor board.20240910_144134.jpgThank you
6 REPLIES 6

So the PB4 / PB5 is on the STM32F446RE or something else?

Which UART

What is wired to what, diagram the actual connectivity, perhaps the initialization code.

What does "The communication is not smooth" mean? You're sending NUL characters in the very limited code snippet you've chosen to share.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
  • So the PB4 / PB5 is on the STM32F446RE or something else? PB4/PB5 is of other processor board.
  •   Which UART  USART1  PA9/PA10 of stm32f446re to PB4/PB5 of other board.
  •  What is wired to what, diagram the actual connectivity, perhaps the initialization code.     PA10-rx to PB4-tx  and PA9-tx to PB5-rx and ground
  • What does "The communication is not smooth" mean? You're sending NUL characters in the very limited code snippet you've chosen to share. 
  • just i want to send a string from nucleo to other board to display, on clicking reset button on the nucleo 4 to 5 times once the string gets displayed.

            

Do you think that's a problem with the sending end or the receiving end?

Have you put a scope or logic analyzer on it? And looked at the signals?

If you're resetting the STM32F446RE is it getting to main() ? Getting stuck in Error_Handler() ? What would prevent it from getting to the code that does the HAL_UART_Transmit() ?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist III

@harry123 wrote:
  • other board is a processor.

What, exactly, does that mean?

How are you certain that the UART reception on that board is working well?

Have you tried other receivers - eg, a terminal on a PC ?

You need to show your full schematics, and your code - see:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

 

Karl Yamashita
Lead III
  • The problem that Im facing is data is getting  displayed on pressing reset button on nucleo several times.

What are you trying to do when you press the reset button? Send "Connect"?

 

  • just i want to send a string from nucleo to other board to display, on clicking reset button on the nucleo 4 to 5 times once the string gets displayed.

This doesn't make sense? Once the string is displayed, you're clicking on the reset button on the nucleo 4-5 times?

 

I think you need to reword what you're actually trying to achieve. Show your code.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
  • Sending a string "Connect" through uart1 of nucleo to mini 6045 processor 
  • Below is the processor code ,its pinout to where im connecting nucelo uart1 i.e PA9 and PA10
  • 20240910_144134.jpgWhatsApp Image 2024-09-12 at 11.14.24 PM.jpeg

 

void MainWindow::loadPortSettings()
{
    PortSettings uartSettings = {BAUD115200, DATA_8, PAR_NONE, STOP_1, FLOW_OFF, 10};
    port = new QextSerialPort("ttySAC2", uartSettings, QextSerialPort::Polling);
    uartTimer = new QTimer(this);
    uartTimer->setInterval(40);
    if(!port->isOpen())
    {
        port->open(QextSerialPort::ReadWrite);


    }
    if(port->isOpen() && port->queryMode()==QextSerialPort::Polling)
    {
        uartTimer->start();

    }
    else
    {
        uartTimer->stop();
    }
    connect(uartTimer,SIGNAL(timeout()),this,SLOT(onReadyRead()));
}

void MainWindow::onReadyRead()
{

    if(port->isOpen()&& port->bytesAvailable())
    {
        manipulateUartData(QString::fromLatin1(port->readAll()));
    }
}
void MainWindow::manipulateUartData(QString str)///////////For Protocols
{
    //  qDebug ()<<"comm"<<communicationEnabled;
    qDebug ()<<"Command: "<<str;

    if(str.contains("Connect"))
    {
        QString rplyINS;
        if(!communicationEnabled)
        {
            rplyINS="1Adtr ON,InsSerialNo="+ strFieldValues[idxUnitCalibrationWindow][csInstrumentSerialNo] +"$";
            informationBox("Connected");
            communicationEnabled=true;
            port->write(rplyINS.toLatin1 ());
        }
        else
        {
            rplyINS="Already Connected,InsSerialNo="+ strFieldValues[idxUnitCalibrationWindow][csInstrumentSerialNo]+ "$";
            informationBox (rplyINS,"Warning");
            if(communicationEnabled)
            {
               // port->write ("Err:Instrument Connected Already");
                 port->write (rplyINS.toLatin1 ());
            }
        }