cancel
Showing results for 
Search instead for 
Did you mean: 

two USART configuration failed (USART3 problem)

parisa
Senior
Posted on March 01, 2017 at 15:27

Hi,

Here is my code for configuring two different usart but my USART3 doesn't work properly and USART2 works fine.(I remap both of them). what is my mistake that I didn't pay attention?

Problem: I don't have any signal on USART3_TX pin when I send a char. however my USART1 works fine(send and receive)

    USART_InitTypeDef USARTConfiguration;

    GPIO_InitTypeDef GPIOS;

        RCC_APB2PeriphClockCmd(RCC_APB1Periph_USART2|RCC_APB1Periph_USART3|RCC_APB2Periph_GPIOD |RCC_APB2Periph_GPIOC |RCC_APB2Periph_AFIO,ENABLE);

 GPIO_PinRemapConfig(GPIO_Remap_USART2|GPIO_PartialRemap_USART3,ENABLE);

    

    GPIOS.GPIO_Mode=GPIO_Mode_AF_PP ;

    GPIOS.GPIO_Speed=GPIO_Speed_50MHz;

    GPIOS.GPIO_Pin=GPIO_Pin_5;

    GPIO_Init(GPIOD,&GPIOS);

    

    GPIOS.GPIO_Mode=GPIO_Mode_IN_FLOATING ;

    GPIOS.GPIO_Pin=GPIO_Pin_6;

    GPIO_Init(GPIOD,&GPIOS);

               

    USARTConfiguration.USART_BaudRate=9600;

    USARTConfiguration.USART_StopBits=USART_StopBits_1;

    USARTConfiguration.USART_WordLength=USART_WordLength_8b;

    USARTConfiguration.USART_Parity=USART_Parity_No ;

    USARTConfiguration.USART_HardwareFlowControl=USART_HardwareFlowControl_None;

    USARTConfiguration.USART_Mode=USART_Mode_Rx | USART_Mode_Tx;

    USART_Init(USART2,&USARTConfiguration);

    USART_ITConfig(USART2,USART_IT_RXNE,ENABLE);

    NVIC_EnableIRQ(USART2_IRQn);

    USART_Cmd(USART2,ENABLE);

    GPIOS.GPIO_Mode=GPIO_Mode_AF_PP ;

    GPIOS.GPIO_Speed=GPIO_Speed_50MHz;

    GPIOS.GPIO_Pin=GPIO_Pin_10;

    GPIO_Init(GPIOC,&GPIOS);

    GPIOS.GPIO_Mode=GPIO_Mode_IN_FLOATING ;

    GPIOS.GPIO_Pin=GPIO_Pin_11;

    GPIO_Init(GPIOC,&GPIOS);  

    

    USARTConfiguration.USART_BaudRate=9600;

    USARTConfiguration.USART_StopBits=USART_StopBits_1;

    USARTConfiguration.USART_WordLength=USART_WordLength_8b;

    USARTConfiguration.USART_Parity=USART_Parity_No ;

    USARTConfiguration.USART_HardwareFlowControl=USART_HardwareFlowControl_None;

    USARTConfiguration.USART_Mode=USART_Mode_Rx | USART_Mode_Tx;

    USART_Init(USART3,&USARTConfiguration);

    USART_Cmd(USART3,ENABLE);

Thanks in advance.

#context-context-context
1 ACCEPTED SOLUTION

Accepted Solutions
parisa
Senior
Posted on March 01, 2017 at 16:32

Thanks for your comment.

You are correct and I did some mistake when I wanted to copy my source code , I fix the above problem but still it doesn't work

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2|RCC_APB1Periph_USART3,ENABLE);

View solution in original post

6 REPLIES 6
AvaTar
Lead
Posted on March 01, 2017 at 16:05

RCC_

APB2

PeriphClockCmd (RCC_

APB1

Periph_USART2|RCC_

APB1

Periph_USART3|RCC_APB2Periph_GPIOD |RCC_APB2Periph_GPIOC |RCC_APB2Periph_AFIO,ENABLE);

Different buses, doesn't match.

parisa
Senior
Posted on March 01, 2017 at 16:32

Thanks for your comment.

You are correct and I did some mistake when I wanted to copy my source code , I fix the above problem but still it doesn't work

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2|RCC_APB1Periph_USART3,ENABLE);
parisa
Senior
Posted on March 01, 2017 at 17:26

Hi,

Thanks for your contribution

I split each line with different lines but it doesn't work again

Posted on March 01, 2017 at 16:55

I don't think you can combine these, split them up

GPIO_PinRemapConfig(GPIO_Remap_USART2|GPIO_PartialRemap_USART3,ENABLE);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
parisa
Senior
Posted on March 01, 2017 at 18:12

Thanks dear friends for your contribution and sorry for taking your time

It was my fault that I have reconfigured port c in other part my my program.

Posted on March 01, 2017 at 17:32

What part specifically are you using? Have you reviewed the Data Sheet and Reference Manuals to make sure the pins and remapping are correct?

Is this some custom board, or one we should be familiar with? Does anything clash at a pin level that might cause them not to function?

Post complete testable code as currently compiling.

#context%20context%20context

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