AnsweredAssumed Answered

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

Question asked by hoodjay on Mar 21, 2014
Latest reply on Mar 21, 2014 by hoodjay
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);
}


Outcomes