AnsweredAssumed Answered

Manually assert RS232 flow control signals

Question asked by Bobo Bobobooobö on Sep 18, 2017
Latest reply on Sep 19, 2017 by Bobo Bobobooobö

Hello,

I'm working on a project using a STM32L476.

I'm using RS232 on the USART1 (with a MAX2328). I'm connecting the RS232 on my computer using a USB adaptator. And I use a RS232 analyzer with LEDs to monitor the flow control signals.

What I would like to do is manually assert DCD, DSR, DTR and RI with GPIOs but when I read the state of one of the pin associed to one of these signals, it's always 0.

This is how I initialize the GPIOs :

//DTR ----> PA8
GPIO_InitTypeDef DTR;
if(Config_RS232.DTR!=DISABLE)
{
if(Config_RS232.DTR==OUTPUT)
{
DTR.Alternate = GPIO_MODE_OUTPUT_PP;
DTR.Mode = GPIO_MODE_OUTPUT_PP ;
DTR.Pin = GPIO_PIN_8;
DTR.Pull = GPIO_NOPULL;
DTR.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA,&DTR);
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_8,1);
}
}
//DCD ----> PC9
GPIO_InitTypeDef DCD;
if(Config_RS232.DCD!=DISABLE)
{
if(Config_RS232.DCD==INPUT)
{
DCD.Pin = GPIO_PIN_9;
DCD.Mode = GPIO_MODE_INPUT;
DCD.Pull = GPIO_NOPULL;
DCD.Speed = GPIO_SPEED_FREQ_LOW;
DCD.Alternate = GPIO_MODE_INPUT;
HAL_GPIO_Init(GPIOC, &DCD);
}
}
//DSR -----> PC8
GPIO_InitTypeDef DSR;
if(Config_RS232.DSR!=DISABLE)
{
if(Config_RS232.DSR==INPUT)
{
DSR.Pin = GPIO_PIN_8;
DSR.Mode = GPIO_MODE_INPUT;
DSR.Pull = GPIO_NOPULL;
DSR.Speed = GPIO_SPEED_FREQ_LOW;
DSR.Alternate = GPIO_MODE_INPUT;
HAL_GPIO_Init(GPIOC, &DSR);
}
}
//RI -----> PC7
GPIO_InitTypeDef RI;
if(Config_RS232.RI!=DISABLE)
{
if(Config_RS232.RI==INPUT)
{
RI.Pin = GPIO_PIN_7;
RI.Mode = GPIO_MODE_INPUT;
RI.Pull = GPIO_NOPULL;
RI.Speed = GPIO_SPEED_FREQ_LOW;
RI.Alternate = GPIO_MODE_INPUT;
HAL_GPIO_Init(GPIOC, &RI);
}
}

Thanks !

Outcomes