Hello everyone,
I am quite new to microcontroller so i need to know how can i send data from Stmf103 microcontroller using UART (using c). I just start learning about this so at 1st i just wanted to send a simple "hello world" using UART from Stmf103rbt6 microprocesssor to a server via wifi. Is there any library for this that i can use? if you give me a head start that would be really helpful.
Hallo I am using the STM32F103R8T6, Want to transfer one character by UASRT. I write this code but I got this error which I can not solve can you help me how can I solve this problem . Error: Flash Download failed - Could not load file 'D:\STM32F10_Fixed\STM32F10\Project\Objects\stm32f103r8t6_.axf'
/* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32f10x_usart.h"
void RCC_Configuration(void); void Delay(__IO uint32_t nCount); void GPIO_Configuration(void); void USART1_Configuration(void);
int main(void) { RCC_Configuration(); GPIO_Configuration(); USART1_Configuration(); ////////////////
//USART_Init();
/////////////////////USART_Init(USE_USART1);
while (1) {
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
USART_SendData(USART1, 'X');
/* set pin */ GPIO_ResetBits(GPIOC, GPIO_Pin_4); ////////////////////// ooo //////// /* Insert delay */ Delay(1000);
/// USART_SendData(USART1, 'T'); ////// if ( GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_1)) ///////////////////////+ ////// { /////////////////////+ ////// GPIO_ResetBits(GPIOC, GPIO_Pin_4); ///////////////////////// A 1 ////////////// Delay(100); ////// } ////////////////////////////////////////////////////////////////// + ////// else //////////////////////////////////////////////////////////////// + ////// { ////////////////////////////////////////////////////////////// + GPIO_SetBits(GPIOC, GPIO_Pin_4); ///////////////////////////////////// Delay(1000); //////} ////////////////////////////////// +
}
/////////////////////////////////////////////////////////////////////////////////////
void USART1_Configuration(void) {
USART_InitTypeDef USART_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; /* Enable GPIO and USART1 clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); /* Configure USART Tx as alternate function push-pull */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART Rx as input floating */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_Init(GPIOA, &GPIO_InitStructure);
/* 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 configuration */ USART_Init(USART1, &USART_InitStructure);
/* Enable USART */ USART_Cmd(USART1, ENABLE); }
////////////////////////////////////////////// void Delay(__IO uint32_t num) { __IO uint32_t index = 0;
/* default system clock is 72MHz */ for(index = (72000 * num); index != 0; index--) { } }
void RCC_Configuration(void) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); ////////////////////////////A
void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure;
//GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1);//
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; //////////////////////////////////////////// 1 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure); //////////////////////////////////// C
#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
/** * @} */
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
///////////////////////////////////////////