2023-06-02 06:51 AM
Hello All,
Recently I started working on the GNSS with STM32, I am very new to STM32 eco-system. I have a IRNSS click from MikroE which has L89H and I am trying to integrate L89H with STM32WL55JC1 controller.
I have implemented the UART with DMA to receive NMEA messages from the L89. I have connected TX, RX, 3,3v, GND pins to STM32's RX, TX, 3.3v, and ground. But when I execute the code no NMEA messages are displayed on the serial monitor. I don't know where I am going wring and I would appreciate to have help for me in this situation.
Please let me know if all the connections are correctly done or do I need to connect any additional pins to my STm32 controller. And if any additional information is required to debug the situation I am happy to share the details.
Kind regards,
Pavan
2023-06-02 07:30 AM
Get a scope on the TX signal from the GPS. NMEA stream should burst once a second.
Double check / confirm baud rate.
Start with polled UART operation, perhaps forwarding to another you use for debugging.
Move to DMA when you known you have data. The DMA functions return immediately, don't use auto/local variables as these lose scope as you leave the subroutine. The data will be present when the callback is called.
2023-06-02 07:41 AM
Hello @Community member
Thanks for your quick response. But I have already tried to use the standard Polled method. I have tried all the possible ways. Yet I cannot see anything in the serial monitor.
2023-06-02 08:33 AM
https://www.mikroe.com/irnss-click
Does the Click unit get a fix when powered? POWER, 1PPS and 3DFIX LEDs do what?
The default baud rate is 921600
Check you can see data bursts on the TX pin, use an oscilloscope or logic analyzer to do a basic confirmation.
Show relevant schematic portions of the connectivity to the STM32WL55
Show the salient code that initializes the pins, clocks and peripheral
2023-06-06 07:59 AM - edited 2023-11-20 04:05 AM
Hello @Community member ,
Sorry for the late response. Before writing the reply I want to test some more things with the module. But unfortunately I cannot fix the issue. I have added Information you have asked in the previous conversation:
When i plugged the device, I can see the PPS LED is blinking which means I device is receiving the satellite signal.
From the documentation it is mentioned that the default baud rate is 9600. So I am using the default baud rate.
I connect the same IRNSS click to the Clicker 2 STM32 controller, and when I uploaded the example GNSS FW I can see the NMEA messages received by the controller. But the same board is not working when I connected to STM32WL55JC1.
I am using the following code to read and print the NMEA messages in the CUBE IDE:
#include "main.h"
#include "malloc.h"
#include "string.h"
UART_HandleTypeDef huart1;
uint8_t* RX_BUFFER = NULL;
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART1_UART_Init();
while (1)
{
RX_BUFFER = (uint8_t*)malloc(400 * sizeof(uint8_t));
HAL_UART_Receive(&huart1,(uint8_t *)RX_BUFFER,350,500);
HAL_Delay(1000);
int size = sizeof(RX_BUFFER);
HAL_UART_Transmit(&huart1,(uint8_t *)RX_BUFFER,size,500);
HAL_Delay(1000);
}
}
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
RCC_OscInitStruct.PLL.PLLN = 24;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK3|RCC_CLOCKTYPE_HCLK
|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1
|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
}
/**
* @brief USART1 Initialization Function
* @param None
* @retval None
*/
static void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 9600;
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;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK)
{
Error_Handler();
}
}
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
HAL_GPIO_WritePin(Wake_up_GPIO_Port, Wake_up_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(Reset_GPIO_Port, Reset_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin : Wake_up_Pin */
GPIO_InitStruct.Pin = Wake_up_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(Wake_up_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : Reset_Pin */
GPIO_InitStruct.Pin = Reset_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(Reset_GPIO_Port, &GPIO_InitStruct);
}
void Error_Handler(void)
{
__disable_irq();
while (1)
{
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
Pin configuration and the settings are as follows:
Clock configuration:
Debugger configuration:
Please let me know if you need more information to for helping me in solving this issue.
Best regards,
Pavan
2023-06-06 09:24 AM
You can't malloc() and sizeof() the buffer in the loop like this.
What's the rationale of pushing the data received out of the same UART?
Read from the UART that the receiver is connected too, write to the UART the terminal is connected too.
Be cognizant that the functions block, and the data is continuous. The ideal way to deal with this is to use a ring/fifo buffer and having things operate concurrently, ie sending and receiving.
IRNSS Click provides the possibility of using both UART and I2C interfaces. The UART interface supports data baud-rate from 4800bps to 921600bps, with 921600bps by default,..
Perhaps this is wrong, put a scope on the signal, confirm it's there, bursting once a second, and what the bit timing is.
2023-06-06 09:37 AM
Super simple one-way forwarding loop
while (1) // Crude, but might suffice for simple port to port forwarding demo
{
uint8_t data;
HAL_UART_Receive(&huart1,&data,1,500);
HAL_UART_Transmit(&huart1,&data,1,500);
}
Perhaps identify your input/output UARTs and PINs, and your anticipated flow of data.