Skip to main content
Bobo Bobobooobö
Associate
September 18, 2017
Question

Manually assert RS232 flow control signals

  • September 18, 2017
  • 4 replies
  • 1672 views
Posted on September 18, 2017 at 16:08

Hello,

I'm working on a project using a STM32L4

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_RSDTR!=DISABLE)
 {
 if(Config_RSDTR==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_RSDCD!=DISABLE)
 {
 if(Config_RSDCD==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_RSDSR!=DISABLE)
 {
 if(Config_RSDSR==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_RSRI!=DISABLE)
 {
 if(Config_RSRI==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 !

#stm32l476 #usart #rs232
This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
September 18, 2017
Posted on September 18, 2017 at 16:37

Review the peripheral settings with your debugger. Make sure the GPIO clocks are enabled.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Bobo Bobobooobö
Associate
September 18, 2017
Posted on September 18, 2017 at 17:04

Sorry, I'm kind of a beginner at this, what do you mean by reviewing the peripheral settings with the debugger ?

The GPIO Clocks are enabled. Also I can control the pin 8 of GPIOA (even though I can't see it on the RS232 tester, write operations seems to work).

Thank you !

Tesla DeLorean
Guru
September 18, 2017
Posted on September 18, 2017 at 17:27

Well debuggers from the likes of Keil and IAR have this 'Peripheral' menu that decomposes the internal registers at a bit level for inspection. Review those in the context of the Reference Manual. Review the documentation for your debugger.

Look at the GPIO peripheral for the bank(s) in question, and look at the RCC to confirm the clocks are enable, and that they are enabled prior to your configuring them, and that the configuration setting stick and match those you set up.

At a board/chip level make sure you are not driving other signals into the outputs. You should be able to write into GPIO->ODR and inspect state via GPIO->IDR

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..