cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L-Discovery and PMB-648 SiRF (GPS Module)

jbh0001
Associate II
Posted on March 21, 2014 at 04:18

Hey there. I am trying to receive TTL messages sent from my PMB-648 to my STM32L-Discovery board on pin PC11 but I'm having trouble. Whenever I debug my code it hangs on the while loop, waiting for data to arrive on the USART3 port.

Could this be an issue with USART vs UART? I believe the GPS module works asynchronously, but I don't think the STM32L has a UART pin, only USART from what I see. Any help would be great.

int main(void)
{
int i = 0;
RCC_Configuration();
/* Init I/O ports */
Init_GPIOs();
Init_USART3();
/* Init Systick */
Config_Systick();
/* Switch on the leds at start */
GPIO_HIGH(LD_PORT,LD_GREEN);
GPIO_HIGH(LD_PORT,LD_BLUE);
/* Main loop */
while (1)
{
while(USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET); /* Waitwhile RX is empty */
i++;
uint16_t rx = USART_ReceiveData(USART3);
if(i % 2 == 0) {
GPIO_TOGGLE(LD_PORT,LD_BLUE);
}
else {
GPIO_TOGGLE(LD_PORT,LD_GREEN);
}
Delay(5);
}
return 0;
void RCC_Configuration(void)
{
/* Enable the GPIOs Clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC|
RCC_AHBPeriph_GPIOD| RCC_AHBPeriph_GPIOE| RCC_AHBPeriph_GPIOH, ENABLE);
/* Enable comparator clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3 | RCC_APB1Periph_COMP | RCC_APB1Periph_LCD | RCC_APB1Periph_PWR,ENABLE);
/* Enable SYSCFG */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG , ENABLE);
/* Allow access to the RTC */
PWR_RTCAccessCmd(ENABLE);
/* Reset Backup Domain */
RCC_RTCResetCmd(ENABLE);
RCC_RTCResetCmd(DISABLE);
/*!< LSE Enable */
RCC_LSEConfig(RCC_LSE_ON);
/*!< Wait till LSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{}
/*!< LCD Clock Source Selection */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
}
void Init_GPIOs (void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure the GPIO_LED pins LD3 & LD4*/
GPIO_InitStructure.GPIO_Pin = LD_GREEN|LD_BLUE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(LD_PORT, &GPIO_InitStructure);
GPIO_LOW(LD_PORT,LD_GREEN);
GPIO_LOW(LD_PORT,LD_BLUE);
/* Configure User Button pin as input */
GPIO_InitStructure.GPIO_Pin = USER_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(BUTTON_GPIO_PORT, &GPIO_InitStructure);
/* Configure USART3 */
/* Port C*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init( GPIOC, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_USART3);
}
void Init_USART3(void)
{
/* USART configuration struct for USART3 */
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 4800;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx;
/* USART configuration */
USART_Init(USART3, &USART_InitStructure);
/* Enable USART */
USART_Cmd(USART3, ENABLE);
}

2 REPLIES 2
Posted on March 21, 2014 at 04:49

A quick scan over the code looks reasonable enough.

Is the baud rate correct?

Can you see the data from the GPS unit on a scope?

Does PC11 conflict with the Glass?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jbh0001
Associate II
Posted on March 21, 2014 at 05:23

Total noob mistake. After stepping away for a bit I checked all the connections and I was not grounding my board correctly. Thanks for the review :D