die UART
…
//---------------------------------------------------------------------- // Titel : UART Beispiel für den STM32F407 //---------------------------------------------------------------------- // Funktion : sendet einen Zähler per UART // Schaltung : UART RxD an PD8 //---------------------------------------------------------------------- // Hardware : STM32F4 Discovery // MCU : STM32F407VGT6 // Takt : 168 MHz // Sprache : ARM C // Datum : 21.01.2013 // Version : 1 // Autor : Alexander Huwaldt //---------------------------------------------------------------------- #include <stddef.h> #include <stdlib.h> #include "hardware.h" void initApplication() { SysTick_Config(SystemCoreClock/100); // UART3 RxT an PortD8 9600,8,n,1 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD,ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_StructInit (&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_USART3); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE); USART_InitTypeDef USART_InitStructure; 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_Tx; USART_Init(USART3, &USART_InitStructure); USART_Cmd(USART3, ENABLE); } int main(void) { SystemInit(); initApplication(); uint8_t data=0; do{ data++; USART_SendData(USART3,data); waitMs(10); } while (true); return 0; } extern "C" void SysTick_Handler(void) { // Application SysTick }