2015-03-01 05:47 PM
I have a project configured the same as the `UART_Hyperterminal_DMA` example from the `STM32Cube_FW_F4_V1.4.0`.
I am reading NMEA strings from a GPS device. When I print byte-by-byte over virtual com (which I have confirmed works) I receive something that looks like this:$GMCV,,,,,,*D
$GVT,,,,,,N*E
$NGA,,,,000999,,,*5
GNSA,1,,,,999,.999
$GSA,,,,,,9,999E
$PGV,,10079
$LV,10*
NG,,,,NA
$RM,V,,,,ND
VT,,,,N*
GNA,,,,0999,,6
GNA,1,,,,,9.9,9.9,9.9*E
$GGS,A1,,,,,,,9999999999992
GPSV,10*
L,1,5
GNL,,V,7AAAAAAAA$G,,,,,,,4D$G,,,,,N2
GNGA,,,,,0,9.,,,*6
$GGS,A1,,,,,,,9999999999*2
GNSAA,,,,,,,,9.,99*
PG,10*
I am using FreeRTOS.
I have checked:
void
USART::task(
void
const
*nothing) {
HAL_StatusTypeDef status;
status = HAL_UART_Receive(&huart1, (uint8_t *) aRxBuffer, RXBUFFERSIZE, 100);
osMessagePut(usartQueue, aRxBuffer[0], 0);
printf
(
''%c''
, aRxBuffer[0]);
while
((status != HAL_OK) || (status != HAL_TIMEOUT)) {
status = HAL_UART_Receive(&huart1, (uint8_t *) aRxBuffer, RXBUFFERSIZE, 100);
printf
(
''%c''
, aRxBuffer[0]);
osMessagePut(usartQueue, aRxBuffer[0], 0);
}
}
extern
''C''
{
void
HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
}
}
Would really appreciate any help.
Thanks!
#hal-usart-stm32f4xx-polling
2015-03-01 06:45 PM
Is the receiver buffer actually a single byte, or multiple. Not a HAL user, but looks to be specifying 100 characters (or some other unspecified size) but only ever printing/forwarding one.
Be careful to understand the number of characters, and that strings probably won't be NUL terminated.2015-03-02 02:37 AM
Hey Clive,
`RXBUFFERSIZE` is 1 so I don't think thats the problem.Here is what the data from the logic analyzer looks like:```$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GNGSA,A,1,,,,,,,,,,,,,9999,99.99,99.99*2E$GPGSV,1,1,00*79$GLGSV,1,1,00*65$GNGLL,,,,,,V,N*7A$GNRMC,,V,,,,,,,,,,N*4D$GNVTG,,,,,,,,,N*2E$GNGGA,,,,,,0,00,99.99,,,,,,*56$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GPGSV,1,1,00*79$GLGSV,1,1,00*65$GNGLL,,,,,,V,N*7A$GNRMC,,V,,,,,,,,,,N*4D$GNVTG,,,,,,,,,N*2E$GNGGA,,,,,,0,00,99.99,,,,,,*56$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GPGSV,1,1,00*79$GLGSV,1,1,00*65$GNGLL,,,,,,V,N*7A$GNRMC,,V,,,,,,,,,,N*4D$GNVTG,,,,,,,,,N*2E$GNGGA,,,,,,0,00,99.99,,,,,,*56$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GPGSV,1,1,00*79$GLGSV,1,1,00*65$GNGLL,,,,,,V,N*7A$GNRMC,,V,,,,,,,,,,N*4D$GNVTG,,,,,,,,,N*2E$GNGGA,,,,,,0,00,99.99,,,,,,*56$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GPGSV,1,1,00*79$GLGSV,1,1,00*65$GNGLL,,,,,,V,N*7A$GNRMC,,V,,,,,,,,,,N*4D$GNVTG,,,,,,,,,N*2E$GNGGA,,,,,,0,00,99.99,,,,,,*56$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E$GPGSV,1,1,00*79$GLGSV,1,1,00*65$GNGLL,,,,,,V,N*7A$GNRMC,,V,,,,,,,,,,N*4D$GNVTG,,,,,,,,,N*2E$GNGGA,,,,,,0,00,99.99,,,,,,*56$GNGSA,A,1,,,,,,,,,,,```It seems to be randomly dropping bytes.2015-03-02 02:45 AM
Increasing the buffer size to 100 then printing it produces a similar result:
```$PGV,,1010,157A\n$LGV,,101,,2*6\r\nGNLL,,,14800V,5E$GNC,500,,,,205,6\n$VT,,,,,,N*E$NGA,04590''```2015-03-02 05:03 AM
Have double checked baud rate to be correct:
`USART1_BRR = 0x222E = 8750 = 84000000/9600 = System Clock / Baud Rate`2015-03-02 06:12 AM
Sorry for seemingly stupid questions, but I never used the Cube/HAL stuff.
What does yourHAL_UART_Receive
() looks like ?
Do you get an interrupt on a DMA complete event ?
That wouldn't make too much sense, you could pick up the uart interrupts directly instead.
In case of multibyte DMA events or polling, how you avoid overflow ? Your GPS transceiver might push new characters in and overwrite the buffer you are about to read.
Any chance to check the OV flag of the UART ?
I never experienced such problems with interrupt-driven StdLib code, up to 115200 baud.