Skip to main content
Visitor II
December 9, 2008
Question

UART0,UART2 conflicts !

  • December 9, 2008
  • 4 replies
  • 757 views
Posted on December 09, 2008 at 10:01

UART0,UART2 conflicts !

    This topic has been closed for replies.

    4 replies

    sr_shindeAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:56

    Hi all,

    I am not getting(Received data)data Via UART0 when both UART0 and UART2 are enabled(all Initialisation is done properly).When I have commented UART2 initialisation then I am able to receive data via UART0.UART0 Tx works in both conditions.

    UART0 Pin(Port 6.6(Rx),6.7(Tx))

    UART2 Pin(Port 3.0(Tx),3.1(Rx))

    How can use both

    Please guide me through

    Regard

    Sai

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:56

    You have to be careful using pins 3.0 and 3.1 for UART2 because they can also be used for UART0. Misconfiguring something can cause some headache as it's not immediately obvious what's going wrong since the code compiles and runs without any other trouble.

    What is the code you use to initialize the pins for UART0 and UART2?

    sr_shindeAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:56

    Hi all

    UART0 configuration is as follows:

    void Init_UART0(unsigned long l_ulg_BaudRate)

    {

    GPIO_InitTypeDef GPIO_InitStructure;

    UART_InitTypeDef UART_InitStructure;

    SCU_APBPeriphClockConfig(__UART0, ENABLE);

    SCU_APBPeriphReset(__UART0, DISABLE);

    SCU_APBPeriphClockConfig(__GPIO6 , ENABLE);

    SCU_APBPeriphReset(__GPIO6, DISABLE);

    //UART0 Rx pin configuration

    GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

    GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;

    GPIO_Init (GPIO6, &GPIO_InitStructure);

    //UART0 Tx pin configuration

    GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

    GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3;

    GPIO_Init (GPIO6, &GPIO_InitStructure);

    //UART0 Configuration

    UART_InitStructure.UART_WordLength = UART_WordLength_8D;

    UART_InitStructure.UART_BaudRate = l_ulg_BaudRate;

    UART_InitStructure.UART_StopBits = UART_StopBits_1;

    UART_InitStructure.UART_Parity = UART_Parity_No ;

    UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;

    UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx;

    UART_InitStructure.UART_FIFO = UART_FIFO_Disable;

    UART_Init(UART0, &UART_InitStructure);

    VIC1->VAiR[1] = (u32)UART0_IRQHandler;

    VIC1->VCiR[1] = 0x20 | 0;

    VIC1->INTSR &= ~(1);

    VIC1->INTER |= (1);

    UART_ITConfig(UART0,UART_IT_Receive, ENABLE); //Enable Receive Interrupt

    UART_Cmd(UART0, ENABLE); //Enable UART0

    }

    UART2 configuration is as follows:

    void Init_UART2(unsigned long l_ulg_BaudRate)

    {

    GPIO_InitTypeDef GPIO_InitStructure;

    UART_InitTypeDef UART_InitStructure;

    SCU_APBPeriphClockConfig(__UART2, ENABLE);

    SCU_APBPeriphReset(__UART2, DISABLE);

    SCU_APBPeriphClockConfig(__GPIO3 , ENABLE);

    SCU_APBPeriphReset(__GPIO3, DISABLE);

    //UART0 Rx pin configuration

    GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

    GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;

    GPIO_Init (GPIO3, &GPIO_InitStructure);

    GPIO_StructInit(&GPIO_InitStructure); //Reset GPIO initstructure

    //UART0 Tx pin configuration

    GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull;

    GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2;

    GPIO_Init (GPIO3, &GPIO_InitStructure);

    //UART0 Configuration

    UART_InitStructure.UART_WordLength = UART_WordLength_8D;

    UART_InitStructure.UART_BaudRate = l_ulg_BaudRate;

    UART_InitStructure.UART_StopBits = UART_StopBits_1;

    UART_InitStructure.UART_Parity = UART_Parity_No ;

    UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;

    UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx;

    UART_InitStructure.UART_FIFO = UART_FIFO_Disable;

    UART_Init(UART2, &UART_InitStructure);

    UART_Cmd(UART2, ENABLE); //Enable UART0

    }

    Let me know if I have done any mistake

    Regards

    Sai

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:56

    When I configure my UARTs, for the Tx GPIO pins, I have:

    GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Disable;

    Somewhat counter-intuitive, but it's been working for me so I guess it's worth a shot.