some question about serial.c
xiangfu
xiangfu at openmoko.org
Mon Jul 28 03:53:19 CEST 2008
the init uart code:
/* init uart0 */
ldr r0, =0x50000000
mov r1, #0x03
str r1, [r0] /* Line control register : Normal,No
parity,1 stop,8 bits */
/* UCON register
:
* [11:10] [9] [8] [7]
[6] [5] [4] [3:2]
[1:0]
* Clock Sel, Tx Int, Rx Int, Rx Time Out, Rx err, Loop-back,
Send break, Transmit Mode, Receive Mode
* 00 1 0 , 0
1 0 0 , 01
01
* PCLK Level Pulse Disable Generate
Normal Normal Interrupt or Polling
*/
ldr r1, =0x245
str r1, [r0, #0x04]
mov r1, #0x00
str r1, [r0, #0x08] /* UART channel 0 FIFO control register,
FIFO disable */
mov r1,
#0x00
str r1, [r0, #0x0c] /* UART channel 0 MODEM control
register, AFC disable */
mov r1, #0x11
str r1, [r0, #0x28] /* ubrdiv */
Andy Green wrote:
> | 2. config uart clock source as PCLK, 16Mhz,
i calculate the PCLK by hand but it is not 16Mhz,
i use follow code calculate the PCLK ( calc_pclk.c )
the output is :
MPLLCON_val: 581745
MPLL: 581745
PCLK: 33333300
ubrdiv: 17
so i set ubrdiv = 0x11
> Make sure you set the GPIO registers for these pins to be in peripheral
> mode not GPIO. See GPHCON.
i change the start.S code
/*
* === PORT H
GROUP
* Ports : GPH10 GPH9 GPH8 GPH7 GPH6 GPH5 GPH4 GPH3
GPH2 GPH1 GPH0
* Signal : CLKOUT1 CLKOUT0 UEXTCLK nCTS1 nRTS1 RXD1 TXD1
RXD0 TXD0 nRTS0 nCTS0
* Binary : 10 , 10 10 ,
11 11 , 10 10 , 10 10 , 10
10
*/
ldr r0, =0x56000070
ldr r1, =0x2afaaa
str r1, [r0]
> There's also a peripheral clock mask register CLKCON, it says it resets
> to all enabled though.
>
i think i do that:
/* init uart0 */
ldr r0, =0x4c00000c /* clkcon */
ldr r1, =0xffff0 /* all clocks on */
str r1, [r0]
i try the UART0 UART1 and UART2 , all now work,
-------------------------------------------------------------------------------
the sent code :
#define UTXH (*(volatile unsigned char *)0x50000020)
#define UTRSTAT (*(volatile unsigned char *)0x50000010)
/*
* Output a single byte to the serial
port.
*/
void serial_putc (const char c)
{
while (!(UTRSTAT & 0x2));
delay(10);
UTXH = c;
}
-----------------------------------------------------------------------
another question:
first i use "sudo modprobe ftdi_sio vendor=0x1457 product=0x5118"
then there are /dev/ttyUSB0 in my PC (something it is /dev/ttyUSB1, and
there no /dev/ttyUSB0)
is the mean if the code is work,then i can get something from /dev/ttyUSB0 ?
there are three UART in s3c2442, which i should use ,
or it is doesn't matter which i use, and h
i really don't know what wrong of this code :-(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: calc_pclk.c
Type: text/x-csrc
Size: 1454 bytes
Desc: not available
Url : http://lists.openmoko.org/pipermail/openmoko-kernel/attachments/20080728/3b23c2eb/attachment.c
More information about the openmoko-kernel
mailing list