Hi, I am new to embedded programing, I work on MINI2440 (S3C2440A), I am trying to write code that implement RS-232 On UART, Can someone explain please on the GPHCON Register what is the difference between TXD to nRTS1, and RXD to nCTS1? 00 = Input 01 = Output 10 = RXD[2] 11 = nCTS1 00 = Input 01 = Output 10 = TXD[2] 11 = nRTS1 what should be the configuration to work in AFC mode (what happen in practice in AFC mode)or to implement RS-232 protocol? Thanks, Tomer
Basic Question
The GPxCON registers essentially specify what function you want to attach to a specified pin. Looking at the schematics GPH7 is connected to the J15 pin, GPH6 to the J11 pin. These pins are then connected to RXD2/TXD2 on CON4 (the third UART port), so if you want to use the port as intended, the valid settings for this register are GPH7 = 10, GPH6 = 10 (or if you want to use HW flow control for UART1 and essentially disable UART2 you can use 11 for both values, this is an ugly hack though since UART0 already provides RTS/CTS and that is the port you'll most likely use). Page 335 (part 11-4) of the documentation tells you everything you need to use AFC. HW flow control is automatically handled if you use the FIFO buffer of the UART port (which is recommended to avoid busy-waiting on TX). You write the data to transmit to the FIFO tx buffer, and it is transmitted when CTS is signaled from the remote end. RTS is also handled automatically in AFC mode. So what you need is: - Set port mode in ULCONn register (nothing special). - Set baudrate & stuff in UCONn register. (for this you need some calculation with the CPU clocks, but still bearable as long as you don't do dynamic frequency scaling), enable transmit & receive interrupts (if you don't want to poll them). - Enable AFC in UMCONn. - Enable & reset FIFO in UFCONn. After that you can start transmitting by writing to UTXHn register until FIFO is full, and wait for buffer empty IRQ. (I seem to remember some issue where the data you wrote to the TX FIFO went down the crapper if the FIFO was empty but there was some data in the FIFO shifter register, although i'm not sure about that and i don't think anybody has ever seen an errata sheet for the S3C2440)