Using 2 UART on STM32?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-11 12:39 AM
Dear Members,
I want to read a result from my GPS,
it's Neo 6M
I initialized 2 UARTs UART 1 for PC and UART 2 for GPS,
I got this result :
INIT CODE GPS NEO - 6M....
From GPS :
Is it receiving properly ?
The code :
char in[8];
printf("From GPS : ");
HAL_UART_Receive(&huart2, (uint8_t *)in, 8, 1000);
HAL_UART_Transmit(&huart1, (uint8_t *)in, 8, 1);
printf("\r\n");
Green LED on GPS module is blinking...
Thanks
- Labels:
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-11 4:15 AM
I would expect NMEA sentences at 9600 8N1
Your HAL functions block, so no ideal for forwarding data.​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-11 4:24 AM
> I would expect NMEA sentences at 9600 8N1
This are the default setting of the module.
Do you have the baudrate of the STM32 MCU set properly ?
And not changed the module's setting to binary UBX messages ?
In addition to the inappropriateness of said HAL functions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-11 4:43 AM
Seems too consistent and wrong data to be UBX. Would need to know more about specific implementation. NAZA​ UAV modules for example output their own packet format.
One could observe data with a scope, or use USB to CMOS Serial directly from NEO-6M module.​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-11 4:47 AM
Does the receive call function or does it return an error? Try clearing the buffer and checking. Post lacks a lot of salient details which would help diagnose situation.
To answer the underlying question, No this doesn't look to be receiving properly/correctly. ​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-11 5:11 AM
void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
}
/* USART2 init function */
void MX_USART2_UART_Init(void)
{
huart2.Instance = USART2;
//huart2.Init.BaudRate = 115200;
huart2.Init.BaudRate = 9600;//NEO6M Baudrate
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
}
UART Setting from STM32CubeMX
@Clive
Which UART buffer should I clear ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-11 5:16 AM
I'm using the module indoor, does it receive signal ?
Or without a signal, at least I can read its ID with UART ?
Is this the right manual ?
or there's another more comprehensive one ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-11 5:17 AM
the module is like this :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-11 5:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-14 2:35 AM
I got output from
serial to PC
May be with interrupt is better ?
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
display to pc here
}
