4 creating communication control routines, 1) void m_io_init( ) – Epson S1C33 User Manual
Page 13

2 IMPLEMENTING THE DEBUG MONITOR
S1C33 FAMILY DEBUG MONITOR
EPSON
OPERATION MANUAL
7
2.4 Creating Communication Control Routines
For communicating with the debugger, the debug monitor calls the following four RS232C routines (1 to 4).
"mon33chX.lib" that contains these routines can be used when using the serial interface Ch.0 or Ch.1 on the S1C33
chip and the S5U1C330MxD1 board. Otherwise, it is necessary to create these routines according to the system
since "mon33.lib" must be used. The sample program "m3s_sci.s" that uses the serial interface Ch.0/Ch.1 of the
S1C33104/S1C33209 is provided in "src\", so use it after modifying if necessary.
(1) void m_io_init( )
This is an initial set-up routine of the serial interface. Return value is not necessary.
Set up I/O terminals, input clock, baud rate and a data format. Select 8-bit asynchronous mode, no parity and 1
stop bit. The baud rate should be set to a value supported by the debugger db33 and the personal computer.
Refer to the "S1C33XXX Technical Manual" for the serial interface and for setting the clock.
The sample program "m3s_sci.s" assumes use of the S5U1C330MxD1 board. It sets the baud rate to 115.2 kbps
when a 1.843 MHz external clock is used.
Example: "m_io_init( ) of "m3s_sci.s"
#define
MON_VER
0x11
;monitor firm-ware version
#ifdef SIO0
#define
STDR
0x000401e0
;transmit data register(ch0)
#define
SRDR
0x000401e1
;receive data register(ch0)
#define
SSR
0x000401e2
;serial status register(ch0)
#define
SCR
0x000401e3
;serial control register(ch0)
#define
SIR
0x000401e4
;IrDA control register(ch0)
#define
PIO_SET
0x07
;port function register
#else
#define
STDR
0x000401e5
;transmit data register(ch1)
#define
SRDR
0x000401e6
;receive data register(ch1)
#define
SSR
0x000401e7
;serial status register(ch1)
#define
SCR
0x000401e8
;serial control register(ch1)
#define
SIR
0x000401e9
;IrDA control register(ch1)
#define
PIO_SET
0x70
;port function register
#endif
#define
SIR_SET
0x0
;SIR set(1/16 mode)
#define
SCR_SET
0x7
;SCR set(#SCLK input 1.843MHz 115200bps)
#define
SCR_EN
0xc0
;SCR enable
#define
PIO
0x000402d0
;IO port (P port) register
.code
;******************************************************************************
;
;
void m_io_init()
;
serial port initial function
;
;******************************************************************************
.global
m_io_init
m_io_init:
ld.w
%r0,SIR_SET
;1/16 mode
xld.b
[SIR],%r0
;SIR set
ld.w
%r0,SCR_SET
xld.b
[SCR],%r0
;SCR set(#SCLK input 1.843MHz)
xld.w
%r0,PIO_SET
xld.b
[PIO],%r0
;IO port set
xld.w
%r0,SCR_EN|SCR_SET
xld.b
[SCR],%r0
;SCR set
ret
In addition to the sample program above, "dmt33001\m3s_sci.s " is provided. This program sets the baud rate to
38,400 bps based on the 20 MHz S1C33104 internal clock. Refer to it if necessary.