STM32F0 USART1 not work
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-09-22 09:43 AM
Posted on September 22, 2012 at 18:43
Hi, I have STM32F0 Discovery, I need send a char example 'A' in USART1 that use PA9 to TX.
The configuration are: /* Enable GPIO clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); //PA9 ,PA10 /* Enable USART clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); /* Connect PXx to USARTx_Tx */ GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_0); //PA9 -> TX /* Connect PXx to USARTx_Rx */ GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_0); //PA10 -> RX /* Configure USART Tx as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_PinSource9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configure USART Rx as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_PinSource10; GPIO_Init(GPIOA, &GPIO_InitStructure); /* USART configuration */ 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); /* Enable USART */ USART_Cmd(USART1, ENABLE); And for trasmit: USART_SendData(USART1, (uint8_t) 'A'); while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); But Not work, the arm runcorrectly
but the output PA9 is null trasmit
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-09-22 03:30 PM
Posted on September 23, 2012 at 00:30
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
.. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-09-23 03:47 AM
Posted on September 23, 2012 at 12:47
Yes!!! now work!! Thanks You!!!