UART0,UART2 conflicts !
Company  
ST Home | Microcontrollers

Index  »  ARM9 STR9  »  UART0,UART2 conflicts !
     
   UART0,UART2 conflicts !
 Moderated by :   »  mirou  -  eris

Author
beginning argument    ( Replies received: 3 )
sr_shinde   Posted 01-12-2008 at 12:36   



Registered on :
06-20-2009

Messages : 23

 OFF-Line

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




 Profile   Quote  
SJackson   Posted 05-12-2008 at 20:33   



Registered on :
02-26-2007

From USA

Messages : 41

 OFF-Line

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?



 Profile   Quote  
sr_shinde   Posted 09-12-2008 at 05:45   



Registered on :
06-20-2009

Messages : 23

 OFF-Line

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




 Profile   Quote  
SJackson   Posted 09-12-2008 at 14:31   



Registered on :
02-26-2007

From USA

Messages : 41

 OFF-Line

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.




 Profile   Quote  
On Top

Search in the forums
 
Jump To