cancel
Showing results for 
Search instead for 
Did you mean: 

Usart serial window viewer

francois
Associate II
Posted on May 08, 2014 at 09:34

Hi, i have a STM32F3Discovery board and i am trying to communicate to a sim900 module. First i am trying to send data serially from the discovery to the computer using hyperterminal on windows 8. I am sending the char ch = 0x49 but on hyper terminal i am receiving the character ''[''.

upon opening my serial window uart1 i can not see anything in it while it is in debug mode and the code is running..is there something i have to specify within hardware or software maybe?

// STM32 USART1 (Tx PA.9, Rx PA.10) STM32F3 Discovery - sourcer32@gmail.com

 

#include ''stm32f3_discovery.h''

 

//****************************************************************************

void Delay(__IO uint32_t nCount);

void RCC_Configuration(void)

{

  /* USART1 clock enable */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

 

  /* GPIOA clock enable */

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

}

 

//****************************************************************************

 

void GPIO_Configuration(void)

{

  GPIO_InitTypeDef GPIO_InitStructure;

 

  /* GPIO Configuration */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

 

  /* Connect USART pins to AF */

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_7);   // USART1_TX

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_7);  // USART1_RX

}

 

//****************************************************************************

 

void USART1_Configuration(void)

{

  USART_InitTypeDef USART_InitStructure;

 

  /* USARTx configuration ------------------------------------------------------*/

  /* USARTx configured as follow:

        - BaudRate = 9600 baud

        - Word Length = 8 Bits

        - One Stop Bit

        - No parity

        - Hardware flow control disabled (RTS and CTS signals)

        - Receive and transmit enabled

  */

  USART_InitStructure.USART_BaudRate = 9600;

  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_Mode_Tx;

 

  USART_Init(USART1, &USART_InitStructure);

 

  USART_Cmd(USART1, ENABLE);

}

 

//****************************************************************************

 

int main(void)

{

  uint16_t ch;

 

  RCC_Configuration();

 

  GPIO_Configuration();

 

  USART1_Configuration();

 

  ch = 0x49; // 'I'

 

  while(1)

  {

    if (USART_GetFlagStatus(USART1, USART_FLAG_TXE) != RESET) // Check for Empty

        {    

            Delay(1000);

      USART_SendData(USART1, ch); // Send Character

        }

   

  }

 

  while(1); // Don't want to exit

}

 

void Delay(__IO uint32_t nCount) //in millisecond

{

  nCount = nCount * 5940 *2;//381;

  while(nCount--)

  {

  }

}

//****************************************************************************

 

#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 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) */

 

  /* Infinite loop */

  while (1)

  {

  }

}

#endif

0 REPLIES 0