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-14 11:30 PM
I have some confuse regarding such type of function
"void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart"
like this also
"HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)"
they are only use before main or any where in main because i am using ADC my program goes in function where is ADC value is used but its' not show me ADC value on my screen so i want to 0 use "HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)" function. it will help or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-15 5:30 AM
is void USART_GPS_IRQHandler(void) // Sync and Queue NMEA Sentences
equal to
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) ?
so I will move the content of that function to this function ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-15 5:31 AM
I don't understand the code ?? how can I connect it with my STM32L152RE ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-15 5:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-15 5:56 AM
the code :
/* USER CODE BEGIN 0 */
void startRx()
{
// pretty inefficient but will probably be ok for 9600
uint32_t offset = (rxChars & 0x1f); // so count is actual receive count but offset is buffer index
HAL_UART_Receive_IT(MYUART, rxBuffer+offset, 1);
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart)
{
if (huart==MYUART)
{
rxChars += 1; // char is already in our buffer, inc count and bail out quickly since this is a callback
}
}
/* USER CODE END 0 */
in main :
printf("From GPS : ");
if (lastRxChars != rxChars)
{
printf("now I have %lu chars\n", rxChars);
lastRxChars = rxChars;
startRx();
}
it never gets inside if ....??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-15 5:59 AM
without
if (lastRxChars != rxChars)
I got :
INIT CODE GPS NEO - 6M....
From GPS : now I have 0 chars
INIT CODE GPS NEO - 6M....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-15 8:07 AM
It is the USART2_IRQHandler() or whatever the #define says it is.
The HAL Callback methods are far too circuitous and not really compatible with the byte-at-a-time interrupts coming from the USART. NMEA data rarely falls on convenient 10 or 100 byte boundaries.
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-15 8:16 AM
Ok, so we're about 25 questions into the thread before the specific STM32 part is identified.
What board is this on? A standard NUCLEO board, or something else?
It would take some effort on my part to port this to the L1 platform.
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-16 5:25 AM
STM32L152LE
It's Nucleo board without a programmer on it, so I use ST-link for it,
Please find STM32CubeMX file below, is it right ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-16 5:50 AM
STM32L152 doesn't have ICR register ...??
can I disable it ?
