2007-06-13 05:36 AM
2007-06-12 04:21 AM
I'm having a problem with the serial ports using the library. Testing with both Com2 and Com3, sending data out at 9600 baud works. The problem that I'm having is with Rx data. I have verified that the source is transmitting correctly. but when connected to the Rx port on the STR735, the signal is at logic 1 and is only slightly being driven low to about 4.4 volts. When the Source is removed from Rx on the STR735 the correct logic levels are being driven.
The following is a snippet of UART initialization code for COM3. CFG_PeripheralClockConfig(CFG_CLK_GPIO6,ENABLE); CFG_PeripheralClockConfig(CFG_CLK_UART3, ENABLE); GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStruct.GPIO_Pins = GPIO_PIN_2 | GPIO_PIN_4; // UART3_Rx & Tx GPIO_Init(GPIO6, &GPIO_InitStruct); UART_StructInit(&UART_InitStruct); UART_InitStruct.UART_BaudRate = 9600; UART_InitStruct.UART_Mode = UART_Mode_8D; UART_InitStruct.UART_Loop_Standard = UART_Standard; UART_InitStruct.UART_StopBits = UART_StopBits_1; UART_InitStruct.UART_FIFO = UART_FIFO_Enable; UART_InitStruct.UART_Rx = UART_Rx_Enable; UART_Init(UART3, &UART_InitStruct); UART_ITConfig(UART3, UART_IT_RxBufNotEmpty, ENABLE); UART_Cmd(UART3, ENABLE); It appears the the Rx pin is set up as a output and it's bucking the external source. Is there anything that I'm missing. Thanks2007-06-12 06:59 AM
Dear,
Only the UART3_Tx pin need to be configured as AF_PP mode. For the UART3_Rx pin it should be configured as input instead of AF push pull. Note, for alternate function inputs, the port must be configured in Input mode. Could you modify the UART3_Rx pin configuration as inputs and let me know if you still have an issue. Thanks.2007-06-12 07:25 AM
If I set Rx to an input instead of an alternate function, then what library call configures the Rx data to be routed to the UART?
Remove GPIO_PIN_2 from the Alternate Function and add the following: GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_TRI_TTL; // inputs GPIO_InitStruct.GPIO_Pins = GPIO_PIN_2; GPIO_Init (GPIO6, &GPIO_InitStruct); I'll give it a try, it will be another 7 hours from now until I get back to the lab. Thanks,2007-06-12 08:11 AM
I just looked through STR73x Software Library Manual. Where does it indicated that outputs should be Alternate Functions and input are Normal Input I/O's?
I have the SPI working with both MISO and MOSI assigned as Alternate Functions.2007-06-12 11:46 AM
Ref Manual STR73xF, Table 3, lists UART's both Transmit data input and output under the Alternate Function Column.
There is no where in the maunual's showing that they should not be setup as Alternate Functions. But again, the scope shows that Rx is acting as an output.2007-06-13 01:38 AM
Hello Javi,
>>Ref Manual STR73xF, Table 3, lists UART's both Transmit data input and output under the Alternate Function Column. => I think you are referring to STR73x datasheet instead of reference manual. Yes, both UART3 Receive Data input and Transmit Data output are listed in AF column because these pins are AF with respectively Port 6.2 & P6.4 which are the main function after reset. Regarding the SPI working with MISO and MOSI configured as Alternate Functions, this is because the Alternate functions MISO, MOSI, consist of bidirectional alternate functions and they must be configured as Alternate Function Output. However, for the UART-Rx as well for timer input capture it must be configured as input mode since it is used only as input. >>There is no where in the maunual's showing that they should not be setup as Alternate Functions. =>In the STR73x reference manual, ''Alternate Function I/O (AF)'' section, it is mentioned that ''Only one alternate function can be used on each pin -For AF input, the port bit can be either in Input or AF configuration'' . Just to clarify, this is stated for all Alternate function inputs without specifying each case. As example for SPI, MOSI & MISO configured as AF output mode and for the UARTX_RX , CANX_RX pins must be configured as input. In the STR73x Software library user manual, there is note for CAN pin configuration. Here is the configuration for the UART3 pins. /* Configure the UART3_Tx_Pin */ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStruct.GPIO_Pins = GPIO_PIN_4; GPIO_Init (GPIO6, &GPIO_InitStruct); /* Configure the UART3_Rx_Pin */ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_TRI_TTL; GPIO_InitStruct.GPIO_Pins = GPIO_PIN_2 ; GPIO_Init (GPIO6, &GPIO_InitStruct) Thanks.2007-06-13 05:22 AM
I made the change and UARTx_Rx is working. The documents are just not clear on the Alternate Function for the UART. I'm using the Keil Tools and under examples, ST wrote a UART example but it only used the Tx for a comPut function. That example should be changed by ST to include a Rx read function. I also used the simulator in Keil to initially implement the UART API's that I wrote and Rx was accepting data the way I initially had it implemented.
ALSO, there is an ERROR in 73x_uart.h. Take a look at the change that I made. This definition agrees with the manual. /*UART flags definition*/ #define UART_Flag_TxFull 0x0200 #define UART_Flag_RxHalfFull 0x0100 #define UART_Flag_TimeOutIdle 0x0080 #define UART_Flag_TimeOutNotEmpty 0x0040 #define UART_Flag_OverrunError 0x0020 #define UART_Flag_FrameError 0x0010 #define UART_Flag_ParityError 0x0008 #define UART_Flag_TxHalfEmpty 0x0004 #define UART_Flag_TxEmpty 0x0002 // #define UART_Flag_RxBufFull 0x0001 - barry - #define UART_Flag_RxBufNotEmpty 0x0001 Thanks,2007-06-13 05:36 AM
Good news.
For the UART_Flag_RxBufFull, you are right. The UART_IT_RxBufFull as well. We are managing these modifications . Thanks. [ This message was edited by: coucou on 13-06-2007 18:13 ]