cancel
Showing results for 
Search instead for 
Did you mean: 

USART1 work fine not any other on STM32F429 Disco

kapilsinghi123
Associate II
Posted on August 14, 2014 at 11:05

Hello All

I am working on STM32F429 with TFT and using DISCOVERY DISCO board Trying to use 2 UARTS ->>>> UART1 and UART 4 or 6 UART4 with PA0 and PA1 pins PA0 is tied to switch but it should show some activity. No Tx or Rx is working whereas same thing work fine on USART 1 Able to run UART1 and is working fine but nor any other! I am using real-term console for this experiment and have leds on my USB to serial for displaying any activity. its really frustrating..... Following is my code May be i am doing some thing wrong

1.
//***************************** USART_SETUP *******************************<br>void USART_SETUP(void)<br>{<br> GPIO_InitTypeDef GPIO_InitStructure;<br> USART_InitTypeDef USART_InitStruct;<br> <br> RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);<br> RCC_APB2PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);<br>// RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);<br> RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);<br> /*<br><br><br> -------------------------- USART1 ---------------------------<br> PA9 is USART1_TX<br> PA10 is USART1_RX<br><br><br>xxxxxxxxxxx PB6 is USART1_TX<br> PB7 is USART1_RX<br><br><br> -------------------------- USART2 ---------------------------<br> PA2 is USART1_TX<br>xxxxxxxxxxx PA3 is USART1_RX<br> <br> PD5 is USART1_TX<br>xxxxxxxxxxx PD6 is USART1_RX<br> <br> -------------------------- USART3 ---------------------------<br>xxxxxxxxxxx PB10 is USART1_TX<br>xxxxxxxxxxx PB11 is USART1_RX<br> <br>xxxxxxxxxxx PC10 is USART1_TX<br> PC11 is USART1_RX<br> <br>xxxxxxxxxxx PD8 is USART1_TX<br>xxxxxxxxxxx PD9 is USART1_RX<br><br><br> -------------------------- USART4 ---------------------------<br> PA0 is USART1_TX<br> PA1 is USART1_RX<br> <br>xxxxxxxxxxx PC10 is USART1_TX<br> PC11 is USART1_RX<br> <br> -------------------------- USART5 ---------------------------<br> PC12 is USART1_TX<br> PC2 is USART1_RX<br> <br> -------------------------- USART6 ---------------------------<br>xxxxxxxxxxx PC6 is USART1_TX<br>xxxxxxxxxxx PC7 is USART1_RX<br> <br> PG14 is USART1_TX<br> PG9 is USART1_RX<br> <br> -------------------------- USART7 ---------------------------<br>xxxxxxxxxxx PE8 is USART1_TX<br>xxxxxxxxxxx PE7 is USART1_RX<br> <br> PF7 is USART1_TX<br> PF6 is USART1_RX<br> <br> -------------------------- USART8 ---------------------------<br>xxxxxxxxxxx PE1 is USART1_TX<br>xxxxxxxxxxx PE0 is USART1_RX<br> */ <br><br><br>/////// Configure USART1 Rx (PA10) as input<br> GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; <br> GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;<br> GPIO_Init(GPIOA, &GPIO_InitStructure);<br><br>/////// Configure USART1 Tx (PA9) as alternate function<br> GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;<br> GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;<br> GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;<br> GPIO_Init(GPIOA, &GPIO_InitStructure); <br> <br> GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_USART1);<br> GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_USART1);<br><br><br><br><br> <br> // Configure UART4 Rx (PA1) as input<br> GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; <br> GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;<br> GPIO_Init(GPIOA, &GPIO_InitStructure);<br><br> // Configure UART4 Tx (PA0) as alternate function<br> GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;<br> GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;<br> GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;<br> GPIO_Init(GPIOA, &GPIO_InitStructure); <br> <br> GPIO_PinAFConfig(GPIOA,GPIO_PinSource0 ,GPIO_AF_UART4);<br> GPIO_PinAFConfig(GPIOA,GPIO_PinSource1 ,GPIO_AF_UART4);<br> <br> <br> <br> <br> <br> // Configure USART6 Rx (PG9) as input<br> GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; <br> GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;<br> GPIO_Init(GPIOG, &GPIO_InitStructure);<br><br> // Configure USART6 Tx (PG14) as alternate function<br> GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;<br> GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;<br> GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;<br> GPIO_Init(GPIOG, &GPIO_InitStructure); <br> <br> GPIO_PinAFConfig(GPIOG,GPIO_PinSource9 ,GPIO_AF_USART6);<br> GPIO_PinAFConfig(GPIOG,GPIO_PinSource14,GPIO_AF_USART6);<br> <br> /* USARTx configured as follow:<br> - BaudRate = 9600 baud <br> - Word Length = 8 Bits<br> - One Stop Bit<br> - No parity<br> - Hardware flow control disabled (RTS and CTS signals)<br> - Receive and transmit enabled<br> */<br> USART_InitStruct.USART_BaudRate = 57600;<br> USART_InitStruct.USART_WordLength = USART_WordLength_8b;<br> USART_InitStruct.USART_StopBits = USART_StopBits_1;<br> USART_InitStruct.USART_Parity = USART_Parity_No;<br> USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;<br> USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;<br> USART_Init(USART1, &USART_InitStruct);<br><br><br> USART_InitStruct.USART_BaudRate = 9600;<br> USART_InitStruct.USART_WordLength = USART_WordLength_8b;<br> USART_InitStruct.USART_StopBits = USART_StopBits_1;<br> USART_InitStruct.USART_Parity = USART_Parity_No;<br> USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;<br> USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;<br> USART_Init(UART4, &USART_InitStruct);<br><br><br> USART_Cmd(USART1, ENABLE);<br> USART_Cmd(UART4, ENABLE);<br>}<br><div></div>

#stm32f429discovery #uart4
2 REPLIES 2
kapilsinghi123
Associate II
Posted on August 14, 2014 at 12:40

Code in normal format

//***************************** USART_SETUP *******************************

void USART_SETUP(void)

{

    GPIO_InitTypeDef GPIO_InitStructure;

    USART_InitTypeDef USART_InitStruct;

    

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

    RCC_APB2PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);

//    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);

    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

    /*

    -------------------------- USART1 ---------------------------

            PA9  is USART1_TX

            PA10 is USART1_RX

xxxxxxxxxxx PB6  is USART1_TX

            PB7  is USART1_RX

    -------------------------- USART2 ---------------------------

            PA2  is USART1_TX

xxxxxxxxxxx PA3  is USART1_RX

            

            PD5  is USART1_TX

xxxxxxxxxxx PD6  is USART1_RX

            

    -------------------------- USART3 ---------------------------

xxxxxxxxxxx PB10 is USART1_TX

xxxxxxxxxxx PB11 is USART1_RX

            

xxxxxxxxxxx PC10 is USART1_TX

            PC11 is USART1_RX

            

xxxxxxxxxxx PD8  is USART1_TX

xxxxxxxxxxx PD9  is USART1_RX

    -------------------------- USART4 ---------------------------

            PA0  is USART1_TX

            PA1  is USART1_RX

            

xxxxxxxxxxx PC10 is USART1_TX

            PC11 is USART1_RX

            

    -------------------------- USART5 ---------------------------

            PC12 is USART1_TX

            PC2  is USART1_RX

            

    -------------------------- USART6 ---------------------------

xxxxxxxxxxx PC6  is USART1_TX

xxxxxxxxxxx PC7  is USART1_RX

            

            PG14 is USART1_TX

            PG9  is USART1_RX

            

    -------------------------- USART7 ---------------------------

xxxxxxxxxxx PE8  is USART1_TX

xxxxxxxxxxx PE7  is USART1_RX

            

            PF7  is USART1_TX

            PF6  is USART1_RX

            

    -------------------------- USART8 ---------------------------

xxxxxxxxxxx PE1  is USART1_TX

xxxxxxxxxxx PE0  is USART1_RX

    */                                       

/////// Configure USART1 Rx (PA10) as input

    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_10;   

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;

    GPIO_Init(GPIOA, &GPIO_InitStructure);

  

/////// Configure USART1 Tx (PA9) as alternate function

    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_9;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;

    GPIO_Init(GPIOA, &GPIO_InitStructure);    

    

    GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_USART1);

    GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_USART1);

    

   // Configure UART4 Rx (PA1) as input

    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_1;   

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;

    GPIO_Init(GPIOA, &GPIO_InitStructure);

  

    // Configure UART4 Tx (PA0) as alternate function

    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_0;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;

    GPIO_Init(GPIOA, &GPIO_InitStructure);    

    

    GPIO_PinAFConfig(GPIOA,GPIO_PinSource0 ,GPIO_AF_UART4);

    GPIO_PinAFConfig(GPIOA,GPIO_PinSource1 ,GPIO_AF_UART4);

    

    

    

    

    

   // Configure USART6 Rx (PG9) as input

    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_9;   

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;

    GPIO_Init(GPIOG, &GPIO_InitStructure);

  

    // Configure USART6 Tx (PG14) as alternate function

    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_14;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;

    GPIO_Init(GPIOG, &GPIO_InitStructure);    

    

    GPIO_PinAFConfig(GPIOG,GPIO_PinSource9 ,GPIO_AF_USART6);

    GPIO_PinAFConfig(GPIOG,GPIO_PinSource14,GPIO_AF_USART6);

    

    /* USARTx configured as follow:

        - BaudRate = 9600 baud  

        - Word Length = 8 Bits

        - One Stop Bit

        - No parity

        - Hardware flow control disabled (RTS and CTS signals)

        - Receive and transmit enabled

  */

  USART_InitStruct.USART_BaudRate = 57600;

  USART_InitStruct.USART_WordLength = USART_WordLength_8b;

  USART_InitStruct.USART_StopBits = USART_StopBits_1;

  USART_InitStruct.USART_Parity = USART_Parity_No;

  USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

  USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

  USART_Init(USART1, &USART_InitStruct);

  USART_InitStruct.USART_BaudRate = 9600;

  USART_InitStruct.USART_WordLength = USART_WordLength_8b;

  USART_InitStruct.USART_StopBits = USART_StopBits_1;

  USART_InitStruct.USART_Parity = USART_Parity_No;

  USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

  USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

  USART_Init(UART4, &USART_InitStruct);

  USART_Cmd(USART1, ENABLE);

  USART_Cmd(UART4, ENABLE);

}

Posted on August 14, 2014 at 14:12

Please don't [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Multiple%20UART%20Problem%20%21%20%21&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx&currentviews=7]cross-post, and use the Code Format Block tool (Paintbrush [<>] icon, upper left)

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