- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using WICED-Studio-6.1 on CYW943907AEVAL1F platform.
We want to use RTS of UART0 (UART0_RTS_OUT:A53) as GPIO.
For example, please teach me how RTS is fixed to high during transmission in apps/snip/uart/uart.c .
Solved! Go to Solution.
- Labels:
-
UART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On analysing further, it is found that the UART0_RTS pin can be either mapped to RTS function or disabled. But it cannot be used as GPIO. You can use any other GPIO pin such as GPIO_15 as GPIO function using the GPIO APIs discussed earlier. Ensure that the GPIO pin is not being used for any other dedicated function in the eval board.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to use RTS of UART0 as GPIO, first check in the datasheet the pin multiplexing of UART0_RTS. It is multiplexed with GPIO_11, GPIO_7 and GPIO_15. If we select GPIO_11 for instance, check the platform pin mapping table in platform.c. The GPIO_11 is mapped to WICED_GPIO_7. In your application code, initialize the GPIO using wiced_gpio_init(WICED_GPIO_7, OUTPUT_PUSH_PULL). The second parameter in the API is pin configuration which you can modify based on your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for answer.
I changed the code as follows but I couldn't see the results.
I monitored J6 pin24 (UART0_RTS_OUT) of CYW943907AEVAL1F by oscilloscope.
I appreciate any helps.
/******************************************************
* Variable Definitions
******************************************************/
wiced_uart_config_t uart_config =
{
.baud_rate = 115200,
.data_width = DATA_WIDTH_8BIT,
.parity = NO_PARITY,
.stop_bits = STOP_BITS_1,
.flow_control = FLOW_CONTROL_DISABLED,
};
wiced_ring_buffer_t rx_buffer;
uint8_t rx_data[RX_BUFFER_SIZE];
/******************************************************
* Function Definitions
******************************************************/
void application_start( )
{
char c;
uint32_t expected_data_size = 1;
/* Initialise ring buffer */
ring_buffer_init(&rx_buffer, rx_data, RX_BUFFER_SIZE );
/* Initialise UART. A ring buffer is used to hold received characters */
wiced_uart_init( WICED_UART_2, &uart_config, &rx_buffer );
wiced_gpio_init( WICED_GPIO_7, OUTPUT_PUSH_PULL ); /* RTS GPIO init */
/* Send a test string to the terminal */
wiced_gpio_output_high( WICED_GPIO_7 ); /* RTS High */
wiced_uart_transmit_bytes( WICED_UART_2, TEST_STR, sizeof( TEST_STR ) - 1 );
wiced_gpio_output_low( WICED_GPIO_7 ); /* RTS Low */
/* Wait for user input. If received, echo it back to the terminal */
while ( wiced_uart_receive_bytes( WICED_UART_2, &c, &expected_data_size, WICED_NEVER_TIMEOUT ) == WICED_SUCCESS )
{
wiced_gpio_output_high( WICED_GPIO_7 ); /* RTS High */
wiced_uart_transmit_bytes( WICED_UART_2, &c, 1 );
wiced_gpio_output_low( WICED_GPIO_7 ); /* RTS Low */
expected_data_size = 1;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since UART0_RTS is to be used as GPIO, the RTS function must be disabled. Go to platform.c, [WICED_UART_2] and assign .rts_pin=NULL and .cts_pin=NULL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you again for your input.
I tried as you wrote but RTS didn't show High.
Any other modification is needed ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you create a separate application to test only WICED_GPIO_7? You can output the pin high in this application for testing purpose. We need to ensure that the GPIO operation works in isolation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I made a program only of WICED_GPIO_7 but RTS doesn't change.
The program is as follows;
/******************************************************
* Function Definitions
******************************************************/
#define UART_RTS (WICED_GPIO_7)
void application_start( )
{
#if 0
char c;
uint32_t expected_data_size = 1;
/* Initialise ring buffer */
ring_buffer_init(&rx_buffer, rx_data, RX_BUFFER_SIZE );
/* Initialise UART. A ring buffer is used to hold received characters */
wiced_uart_init( WICED_UART_2, &uart_config, &rx_buffer );
wiced_gpio_init( UART_RTS, OUTPUT_PUSH_PULL ); /* RTS GPIO init */
/* Send a test string to the terminal */
wiced_gpio_output_high( UART_RTS ); /* RTS High */
wiced_uart_transmit_bytes( WICED_UART_2, TEST_STR, sizeof( TEST_STR ) - 1 );
wiced_gpio_output_low( UART_RTS ); /* RTS Low */
/* Wait for user input. If received, echo it back to the terminal */
while ( wiced_uart_receive_bytes( WICED_UART_2, &c, &expected_data_size, WICED_NEVER_TIMEOUT ) == WICED_SUCCESS )
{
wiced_gpio_output_high( UART_RTS ); /* RTS High */
wiced_uart_transmit_bytes( WICED_UART_2, &c, 1 );
wiced_gpio_output_low( UART_RTS ); /* RTS Low */
expected_data_size = 1;
}
#else /* temp */
wiced_gpio_init( UART_RTS, OUTPUT_PUSH_PULL ); /* RTS GPIO init */
while ( 1 )
{
wiced_gpio_output_high( UART_RTS ); /* RTS High */
wiced_rtos_delay_milliseconds( 1000 );
wiced_gpio_output_low( UART_RTS ); /* RTS Low */
}
#endif
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On analysing further, it is found that the UART0_RTS pin can be either mapped to RTS function or disabled. But it cannot be used as GPIO. You can use any other GPIO pin such as GPIO_15 as GPIO function using the GPIO APIs discussed earlier. Ensure that the GPIO pin is not being used for any other dedicated function in the eval board.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the answer.
I understood that J6 pin24 (UART0_RTS_OUT) can't be used as GPIO.