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 communication 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 RGB
 R
 MPEG register (RGB data)
 CDC_GetMpegPtr
* All access widths are 16 bits (1 word)

The details of the communication register are shown below.

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

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

Table 3.2 Data transfer register bit configuration
 Register name
 R / W
 15
 14
 13
 12
 11
 Ten
 9
 8
 DATATRNS
 R / W 
 7
 6
 Five
 Four
 3
 2
 1
 0 

  1. The initial value of the bit is indefinite.

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

Table 3.3 Interrupt factor register bit configuration
 Register name
 R / W
 15
 14
 13
 12
 11
 Ten
 9
 8
 HIRQREQ
 R / W
 MPST
 MPCM
 MPED
 SCDQ
 EFLS
 ECPY
 7
 6
 Five
 Four
 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: Ready for data transfer
 0
 bit2
 CSCT
 1: 1 sector read completed

(One sector read from the CD-ROM is stored or erased in the 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: Disc replacement occurred (tray opened)
 0 *
 bit6
 ESEL
 1: Soft reset, end of selector setting process
 1
 bit7
 EHST
 1: End of host I / O processing
 1
 bit8
 ECPY
 1: Completion of copy / move processing between buffer partitions
 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 indefinite section
 0
 bit13
 MPST
 1: Notification of MPEG interrupt status (MPEG-related interrupt generation)
 0
 bit14
 Reserved bit
 0
 bit15
 Reserved bit
 0

* DCHG = 1 at the time of hard reset, but it is cleared to 0 in the BOOT ROM.
DCHG is not initialized during a soft reset. (CDC function writes 0BE1H)
As a general rule, DCHG assumes that the BOOT ROM clears 0 at the time of disk check.

  1. Bits can only be written to 0 (clear).

  2. The IRQ output to the host is the OR output of all factors.
    Clear the relevant factor bit during interrupt processing.

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

  4. The initial values of the bits are CMOK, the command end flag is 1, and the others are 0.
    (Initial value bit pattern: 0BC1H)
    Actually, the bits other than 1 are indefinite, so the CDC function clears 0.

(3) Interrupt mask register (HIRQMSK)
A register for masking interrupts from the CD block to the host.

Table 3.4 Interrupt register bit configuration
 Register name
 R / W
 15
 14
 13
 12
 11
 Ten
 9
 8
 HIRQMSK
 R / W
 MPST
 MPCM
 MPED
 SCDQ
 EFLS
 ECPY
 7
 6
 Five
 Four
 3
 2
 1
 0
 EHST
 ESEL
 DCHG
 PEND
 BFUL
 CSCT
 DRDY
 CMOK

  1. The meaning of the bit is the same as that of the interrupt factor register.
    (1: Interrupt enabled, 0: mask)

  2. If the interrupt is masked, it will be as follows when the interrupt signal is input.
    -It is not reflected in the IRQ output.
    -It is reflected in the interrupt factor register. (Polling process possible)

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

(4) MPEG register (MPEGRGB)
A register for transferring the image data of the MPEG frame buffer to the host in RGB format.

Table 3.5 MPEG register bit configuration
 Register name
 R / W
 15
 14
 13
 12
 11
 Ten
 9
 8
 MPEG RGB
 R 
 7
 6
 Five
 Four
 3
 2
 1
 0 

bit0 to bit15: RGB data (see MPEG part for details)

3.2 Communication method

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

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

(3) Command issuance rules
Issuing commands must comply with the following rules.

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

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

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

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

<< Program guidelines >>
Polling processing by issuing commands continuously is prohibited.
Use regular responses and interrupt cause registers to poll for state changes. It also issues commands using the timing of the SCDQ, CSCT flags, VSYNC, etc.

(4) Command end flag
Notifies the end of processing to commands whose processing does not end (it takes time to process) only by command / response. Commands that belong to the same end flag cannot be executed during command processing. (See the MPEG part for the MPED flag)

Table 3.6 Commands belonging to the command end flag (CD part)
 flag
 command
 ESEL
 -Setting the connection destination of the CD device (CDC_CdSetCon)
-Aperture frame address range setting (CDC_SetFiltRange)
・ Aperture subheader condition setting (CDC_SetFiltSubh)
・ Aperture mode setting (CDC_SetFiltMode)
-Setting the connection destination of the aperture (CDC_SetFiltCon)
-Reset selector (CDC_ResetSelector)
・ Calculation of actual data size (CDC_CalActSiz)
-Execute frame address search (CDC_ExeFadSearch)
-Sector length setting (CDC_SetSctLen)
 EHST
 -Sector data retrieval (CDC_GetSctData)
-Erase sector data (CDC_DelSctData)
-Getting out and erasing sector data (CDC_GetdelSctData)
-Writing sector data (CDC_PutSctData)
 ECPY
 -Sector data copy (CDC_CopySctData)
-Move sector data (CDC_MoveSctData)
 EFLS
 -Move directory (CDC_ChgDir)
-Retention of file information (CDC_ReadDir)
-Reading a file (CDC_ReadFile)

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

  2. The EFLS flag will also be 1 if you run the following command:
    -Tray open (CDC_CdOpen)
    -Cancel file access (CDC_AbortFile)

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

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

  2. If 1, the command end flag is cleared to 0 and the command is issued.

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

Table 3.7 Handling Exceptional Command End Flags
 flag
 command
 0 Clear only (do not check)
 ESEL
 -Soft reset (specified by the parameter of CDC_CdInit)
 EFLS
 -Cancel file access (CDC_AbortFile)
 Just check (do not clear 0)
 ESEL
 -Getting the actual data size (CDC_GetActSiz)
-Getting frame address search results (CDC_GetFadSearch)

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

(7) Precautions for CDC library
The value of the command end flag held by the CDC will be inconsistent when the separately linked CDC program code is executed. Therefore, if the command end flag is not initialized, the command may not be issued.
Keep the following in mind when using the CDC library:
  1. As a general rule, only one program code is resident in memory and used.
  2. When executing another program code, be sure to perform a soft reset first to initialize the command end flag.

3.3 Response

(1) Response content
The response consists of a 1-byte status and a 7-byte report. The status is common, but the report depends on the command. The most basic report is the CD report.

(2) Status
The status returns the following information:

・ REJECT
 : The command itself is invalid, such as 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 required.
・ 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 by the host.

  1. The response at the time of REJECT is invalid.

  2. Drive status and CD reports during WAIT are valid, but other reports are invalid.

(3) Regular response
The periodic response is a response that the CD block returns at the timing of communication with the CD drive, and the host can obtain information (status and CD report) without issuing a command.
It is updated regularly in the communication cycle with the CD drive. (The update timing of the SCDQ flag is the same)

・ During standard speed playback: 13.3ms
Periodic response update cycle ・ At double speed playback: 6.7ms
・ Other than playback: 16.7ms

The periodic response is not updated during the command / response. After reading the response by the command, it will be updated and available at the next CD drive communication timing.

caution
The update cycle of the periodic response (SCDQ flag) shown here is the normal value. The update cycle may be extended depending on the communication status with the CD drive.
(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 procedure is shown below.

  1. Execute a command (extract / write data) that involves data transfer.

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

  3. Data is input and output through the data transfer register.
    To get a pointer to a register, execute the CDC_GetDataPtr function.

  4. After transferring the required data, execute End Data Transfer (CDC_DataEnd).

(2) End of data transfer
If there is a data transfer request in the status, it is necessary to execute the end of data transfer even if the data is not actually transferred or an error occurs. Not required for REJECT and WAIT.
If an error occurs while waiting for the data transfer, the application does not need to perform the end of the data transfer. It is automatically executed inside the waiting function.

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

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

(4) Prohibitions
If you execute a command that involves data transfer, you must not terminate the data transfer before the DRDY flag goes to 1. Be sure to wait for the DRDY flag to set to 1 before quitting, even if you don't actually transfer the data.
(Wait for data transfer and then terminate)


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