cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with definition GPIO with UART0

stol
Associate II
Posted on November 29, 2007 at 17:41

Problem with definition GPIO with UART0

2 REPLIES 2
stol
Associate II
Posted on May 17, 2011 at 09:48

Good afternoon,

I´m newbie here and new in working with STR912FW44. I need advice. I have a problem with correct definition gpio pins to functions for UART0. Code for UART is correct, when I simulated them, it was ok, but inicialization gpio 3.3 for RTS and 5.1 for Rx and 3.4 for Tx is incorect. When I want to use function GPIO_DeInit(GPIO3) and same for GPIO5, it didnt set gpio 3.,3.3 and 5.3, when I use that pins it doesn´t work correct. How to improve the function of that pins?

Thanks Oldriska

m_j_butcher
Associate II
Posted on May 17, 2011 at 09:48

Hi Oldriska

Here is some code which can be used to set up RX and TX lines for UART0 use. The RTS can be set up in a similar fashion, but I don't have verified code for it.

// Set UART0 - TX0 is P3.4 (2nd function) / UART RX0 is P5.1

#define MASK_FUNCTION 0x03

#define PORT_OUT_FUNCTION 0x01

#define ALT_OUTPUT_2_FUNCTION 0x02

#define ALT_OUTPUT_3_FUNCTION 0x03

#define PORT5_BIT1 0x02

SCU_GPIOOUT3 &= ~(MASK_FUNCTION << (2*4));

SCU_GPIOOUT3 |= (ALT_OUTPUT_3_FUNCTION << (2*4));

SCU_GPIOOUT5 &= ~(MASK_FUNCTION << (2*1));

SCU_GPIOIN5 |= PORT5_BIT1;

Don't forget to also enable the UART using something like:

SCU_PCGR1 |= UART1; // enable clocks to UART1

SCU_PRR1 |= UART1; // take UART1 out of reset

Regards

Mark Butcher

http://www.uTasker.com