2019-12-19 05:12 AM
Firstly I had done my code in keil software of stm32 nucleo f446re and try to transfer data to
Arduino Maga in Arduino IDE.I had used UART communication betwen arduino mega and stm32.When I passed a string from keil to arduino ide , there was no response in arduino ide also in arduino IDE there is no any value printed on Serial monitor.
Can anyone please tell me about how to do it?
2019-12-19 07:53 AM
You'd need to have a common ground between the boards.
You'd connect the STM32 UART_TX pin to the MEGA side UART_RX pin equivalent.
Would suggest sending out a stream of 'U' characters from one board, scoping the pin to confirm the signal, and then connecting it to the other end, and checking the data stream is received properly.
2019-12-20 02:51 AM
hello thanks for your help first but I'm still not getting the correct reading in arduino serial COM.
what I've done I'm going to show you...
transmitter code in keil:
I WRITE ONLY MAIN LOGIC WHICH I HAVE MADE HERE ....
#include "main.h"
#include "stm32f4xx_hal.h"
UART_HandleTypeDef huart2;
uint8_t tx[32]="U\r\n";
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART2_UART_Init(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART2_UART_Init();
/* main logic to transfer data from uart communication*/
while (1)
{
HAL_UART_Transmit(&huart2,tx,2,10);
HAL_Delay(1);
}
}
RECIVER CODE IN ARDUINO IDE: /* i coonect the PA2 (TX) PIN TO RX 2 PIN OF ARDUINO & PA3(RX) PIN OF STM32 NUCLEO TO TX2 PIN F ARDUINO MEGA.*/
int tx;
void setup()
{
Serial.begin(9600);
Serial2.begin(9600);
}
void loop()
{
if(Serial,available())
{
data=Serial2.read();
Serial.println(data);
}
2019-12-20 04:09 AM
Only need to send the U, so one character, not 2 or 3.
Use a scope, or a logic probe, to see/hear a square wave on the TX pin, you're trying to establish which end the coding issue is on.