2014-08-19 07:39 PM
I am communicating with an STM32F407 from a computer via Serial. I would like to implement flow control, but I have some questions.
1) Can I manually control the RTS line, so that I can receive a command from the PC and process it, then be ready to receive data, rather than get swamped by data2) How would I set/reset this pin?Cheers #discovery #flowcontrol #stm32f42014-08-19 08:11 PM
Configure it as a GPIO pin (instead of Alternate Function), and drive it high/low as you would any other GPIO pin.
2014-08-19 08:26 PM
/* GPIOG Peripheral clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
/* Configure PG6 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; // Something appropriate
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOG, &GPIO_InitStructure);
GPIO_ResetBits(GPIOG, GPIO_Pin_6); // PG6 Low
GPIO_SetBits(GPIOG, GPIO_Pin_6); // PG6 High