Japanese
PROGRAMMER'S GUIDECD communication I/F (CD part)
BackForward
CD communication interface user's manual

Communication with CD block


3.1 Communication register

Table 3.1 shows a list of registers for communicating with the CD block and the corresponding access functions.

Table 3.1 List of communication registers
 register name
 R/W
 explanation
 access function
 DATATRNS
 R/W
 data transfer register
 CDC_GetDataPtr
 HIRQREQ
 R/W
 Interrupt factor register
 CDC_GetHirqReq
CDC_ClrHirqReq
 HIRQMSK
 R/W
 interrupt mask register
 CDC_GetHirqMsk
CDC_SetHirqMsk
 MPEG GGB
 R
 MPEG register (RGB data)
 CDC_GetMpegPtr
* All access widths are 16 bits (1 word)

Details of the communication registers are shown below.

In the figure, reserved bits are represented by "-". Always specify 0 for reserved bits.
The bit configuration is 15 for the most significant bit (MSB) and 0 for the least significant bit (LSB).

(1)Data transfer register (DATATRNS)
This register inputs and outputs data between the host and CD block during data transfer.
The inside of the register is a FIFO, and when the host retrieves data, the CD block automatically sets the data. (The same applies when writing data)

Table 3.2 Bit configuration of data transfer register
 register name
 R/W
 15
 14
 13
 12
 11
 10
 9
 8
 DATATRNS
 R/W 
 7
 6
 5
 4
 3
 2
 1
 0 
    
    
    
    
    
    
    
    

  1. The initial value of the bit is undefined.

(2) Interrupt factor register (HIRQREQ)
This is an interrupt factor register from the CD block to the host.
Each bit can only be set from the CD block, and each bit can only be cleared from the host. The host clears the target bit and waits for it to become 1.

Table 3.3 Bit configuration of interrupt factor register
 register name
 R/W
 15
 14
 13
 12
 11
 10
 9
 8
 HIRQREQ
 R/W
 MPST
 MPCM
 MPED
 SCDQ
 EFLS
 ECPY
 7
 6
 5
 4
 3
 2
 1
 0
 EHST
 ESEL
 DCHG
 PEND
 BFUL
 CSCT
 DRDY
 CMOK

 bit
 Name
 explanation
 initial value
 bit0
 CMOK
 1: Command can be issued (response set completed)
 1
 bit1
 DRDY
 1: Data transfer ready
 0
 bit2
 CSCT
 1: 1 sector read completed

(One sector read from CD-ROM was stored or erased in a partition)

 0
 bit3
 BFUL
 1: CD buffer full (CD buffer is full)
 0
 bit4
 PEND
 1: End of CD playback (current FAD is out of playback range)
 0
 bit5
 DCHG
 1: Disk replacement occurred (tray opened)
 0※
 bit6
 ESEL
 1: Soft reset, end of selector setting process
 1
 bit7
 EHST
 1: End of host input/output processing
 1
 bit8
 ECPY
 1: End of copy/move processing between buffer sections
 1
 bit9
 EFLS
 1: End of CD block file system processing
 1
 bit10
 SCDQ
 1: Subcode Q update completed (CD drive communication timing)
 0
 bit11
 MPED
 1: End of MPEG related processing
 1
 bit12
 MPCM
 1: End of MPEG operation undefined section
 0
 bit13
 MPST
 1: MPEG interrupt status notification (MPEG-related interrupt occurrence)
 0
 bit14
 reserved bit
 0
 bit15
 reserved bit
 0

* DCHG=1 at hard reset, but cleared to 0 in BOOT ROM.
DCHG is not initialized at soft reset. (CDC function writes 0BE1H)
As a general rule, DCHG shall clear the BOOT ROM to 0 when checking the disk.

  1. Only 0 (clear) can be written to the bit.

  2. The IRQ output to the host is the OR output of all factors.
    When processing interrupts, clear the corresponding factor bit.

  3. The ESEL, EHST, ECPY, EFLS, and MPED bits are collectively called the command end flag.
    Notifies the end of execution of commands belonging to each flag.

  4. The initial values of the bits are 1 for CMOK and command end flag, and 0 for others.
    (Initial value bit pattern: 0BC1H)
    In reality, bits other than 1 are undefined, so the CDC function clears them to 0.

(3) Interrupt mask register (HIRQMSK)
This register is used to mask interrupts from the CD block to the host.

Table 3.4 Bit configuration of interrupt register
 register name
 R/W
 15
 14
 13
 12
 11
 10
 9
 8
 HIRQMSK
 R/W
 MPST
 MPCM
 MPED
 SCDQ
 EFLS
 ECPY
 7
 6
 5
 4
 3
 2
 1
 0
 EHST
 ESEL
 DCHG
 PEND
 BFUL
 CSCT
 DRDY
 CMOK

  1. The meaning of the bits is the same as the interrupt factor register.
    (1: Interrupt enabled, 0: Masked)

  2. When interrupts are masked, the following occurs when an interrupt signal is input.
    ・ Not reflected in IRQ output.
    ・ It is reflected in the interrupt factor register. (Polling processing possible)

  3. The initial value of all bits is 0. (It will not be initialized by soft reset)

(4)MPEG register (MPEGRGB)
This register is used to transfer MPEG frame buffer image data to the host in RGB format.

Table 3.5 MPEG register bit configuration
 register name
 R/W
 15
 14
 13
 12
 11
 10
 9
 8
 MPEG GGB
 R 
 7
 6
 5
 4
 3
 2
 1
 0 
    
    
    
    
    
    
    
    

bit0 to bit15: RGB data (please refer to the MPEG part for details)

3.2 Communication method

(1) Communication time
All interrupts are disabled during the command/response response time. Response time can be delayed if commands are issued consecutively.

(2) Communication error
If the CD block does not respond (returns a response) within the specified time after issuing a command, a communication timeout error will occur. The presence or absence of a response is determined by polling a certain number of times using a software loop.

(3) Command issuance regulations
Issuing commands must comply with the following regulations:

  1. The maximum number of commands that can be issued in any 6.7ms is 30 times.

  2. The maximum number of commands that can be issued in any 16.7ms is 60 times.

  3. For subcode retrieval, the command can be issued up to 34 times in any 13.3ms.
    (16 subcodes R to W + 1 subcode Q acquired: total 17 x 2 = 34 times)

  4. Commands belonging to the same command end flag are issued after waiting for processing to complete.

《Program guidelines》
Polling processing by continuously issuing commands is prohibited.
Use periodic responses and interrupt factor registers to poll for changes in status. Also, commands are issued using timings such as SCDQ, CSCT flags, and VSYNC.

(4) Command end flag
Notifies the end of processing for commands that cannot be completed with just the command/response (processing takes time). During command processing, commands belonging to the same end flag cannot be executed. (See MPEG part for MPED flag)

Table 3.6 Commands belonging to command end flag (CD part)
 flag
 command
 ESEL
 - Setting the CD device connection destination (CDC_CdSetCon)
・ Setting the aperture frame address range (CDC_SetFiltRange)
・ Setting aperture subheader conditions (CDC_SetFiltSubh)
・ Setting the aperture mode (CDC_SetFiltMode)
・ Setting the aperture connection destination (CDC_SetFiltCon)
・ Reset selector (CDC_ResetSelector)
・ Calculating actual data size (CDC_CalActSiz)
・ Execute frame address search (CDC_ExeFadSearch)
・ Setting sector length (CDC_SetSctLen)
 EHST
 - Retrieving sector data (CDC_GetSctData)
・ Erase sector data (CDC_DelSctData)
・ Retrieve and erase sector data (CDC_GetdelSctData)
・ Write sector data (CDC_PutSctData)
 ECPY
・Copy sector data (CDC_CopySctData)
・ Moving sector data (CDC_MoveSctData)
 EFLS
・Move directory (CDC_ChgDir)
・ Retaining file information (CDC_ReadDir)
・ Read file (CDC_ReadFile)

  1. The ESEL flag also notifies the end of soft reset (CDC_CdInit) processing.

  2. The EFLS flag will also be 1 if you run the following command:
    ・ Open tray (CDC_CdOpen)
    ・ Abort file access (CDC_AbortFile)

(5) Exclusive processing of command issuance (in CD communication interface function)
The CDC function checks the flag after the command completes and performs the following exclusive processing.

  1. If the command end flag is 0, an error is returned without issuing the command.

  2. If it is 1, clear the command end flag to 0 and issue the command.

In exceptional cases, the command end flag may be cleared to 0 or only checked.

Table 3.7 Handling exceptional command termination flags
 flag
 command
 Only clear 0 (do not check)
 ESEL
・Soft reset (specified by CDC_CdInit parameter)
 EFLS
・Abort file access (CDC_AbortFile)
 Only check (do not clear to 0)
 ESEL
・Getting the actual data size (CDC_GetActSiz)
・ Obtain frame address search results (CDC_GetFadSearch)

(6) Command end flag at REJECT, WAIT
If REJECT or WAIT is returned in response to a command, the command end flag will not be set to 1. Therefore, the value of the command end flag is retained within CDC so that the command can be issued even after REJECT or WAIT. The CDC function checks this value and performs exclusive processing for issuing commands.

(7) Notes on CDC library
The value of the command termination flag held by CDC will be inconsistent if separately linked CDC program code is executed. Therefore, if the command end flag is not initialized, it may not be possible to issue commands.
Please note the following points when using the CDC library:
  1. As a general rule, only one program code resides in memory and is used.
  2. When executing another program code, always execute a soft reset first to initialize the command end flag.

3.3 Response

(1)Response content
The response consists of 1 byte status and 7 bytes report. Status is common, but reporting is command dependent. The most basic report is the CD report.

(2)Status
The following information is returned in the status:

・REJECT
 : The command itself is invalid, such as because the command format is incorrect.
・WAIT (execution pending)
 :The command cannot be accepted because it cannot be executed in the current state.
・Data transfer request
 : Indicates that data transfer is necessary.
・Regular response
 : Indicates whether it is a regular response or a response to a command.
・CD drive status
 : Indicates the logical state of the CD drive as seen from the host.

  1. The response when REJECT is invalid.

  2. Drive status and CD reports during WAIT are enabled, but other reports are disabled.

(3) Regular response
Periodic responses are responses that the CD block returns when communicating with the CD drive, and the host can obtain information (status and CD report) without issuing a command.
It is updated periodically according to the communication cycle with the CD drive. (SCDQ flag update timing is also the same)

・Standard speed playback: 13.3ms
Periodic response update cycle - During double speed playback: 6.7ms
・Other than during playback: 16.7ms

Periodic responses are not updated during command/response. After reading the response from the command, it will be updated and available for acquisition at the next CD drive communication timing.

Note: The periodic response (SCDQ flag) update cycle shown here is the normal value. The update cycle may be extended depending on the communication status with the CD drive.
(For example, when communication with the CD drive fails due to scratches on the disc, etc.)

3.4 Data transfer

(1) Data transfer procedure
For commands that involve data transfer, the host must perform data transfer processing after the command/response. The steps are shown below.

  1. Executes commands that involve data transfer (extracting/writing data).

  2. Execute Waiting for data transfer preparation (CDC_DataReady). (Wait for DRDY to become 1)

  3. Data is input/output through the data transfer register.
    To obtain the register pointer, execute the CDC_GetDataPtr function.

  4. After transferring the necessary data, execute the end of data transfer (CDC_DataEnd).

(2) Termination of data transfer
If the status is data transfer requested, you must always terminate the data transfer even if no data is actually transferred or an error occurs. Not required at REJECT, WAIT.
If an error occurs while waiting for data transfer to be prepared, the application does not need to terminate the data transfer. It is automatically executed inside the ready function.

(3)Data transfer error
Table 3.8 shows the errors that occur while waiting for data transfer preparation.

Table 3.8 Data transfer error
 Data transfer error
 explanation
 Data transfer timeout
 The CD block does not become ready for data transfer within the specified time.
(DRDY flag does not become 1)
 Unable to secure sector for writing
 A free sector could not be secured when writing sector data.
(DRDY flag remains 0, EHST flag becomes 1)

(4) Prohibited matters
When executing a command that involves data transfer, do not terminate the data transfer before the DRDY flag becomes 1. Even if no data is actually transferred, be sure to wait for the DRDY flag to become 1 before terminating.
(Execute wait for data transfer preparation and then terminate)


BackForward
PROGRAMMER'S GUIDECD communication I/F (CD part)
Copyright SEGA ENTERPRISES, LTD., 1997