8XC196MC, MD, MH USER’S MANUAL

The following example uses EPA0 to capture the SCK signal and P2.3 to receive the data (RXD). It sets up a synchronous serial I/O PTS routine that receives 16 bytes with eight data bits. Because this example uses an external serial clock input, the TIMER1 and BAUD registers are not used. The external clock source controls the baud rate. This example uses several user-defined regis- ters. R_COUNT defines the number of bytes to receive and RXDDONE is a flag that is set when all bytes are received.

1.Disable the interrupts and the PTS.

Use the DI instruction to disable all standard interrupts and the DPTS instruction to disable the PTS.

2.Set-up the stack pointer.

3.Reset all interrupt mask registers.

Clear INT_MASK, INT_MASK1and PI_MASK.

4.Initialize P2.0 to function as the EPA0 input (SCK) and P2.3 to function as RXD.

Set P2_DIR bits 0 and 3 (selects input).

Set P2_MODE.0 (selects special function).

Clear P2_MODE.3 (selects LSIO function).

Set P2_REG bits 0 and 3 (initializes SCK and RXD input to “1”).

5.Initialize the PTSCB as shown in Table 5-14.

Table 5-14. SSIO Receive Mode PTSCBs

PTSCB1

PTSCB2

 

 

PTSVEC (H) = pointer to PTSCB2

Unused

 

 

PTSVEC (L) = pointer to PTSCB2

SAMPTIME = unused

 

 

BAUD (H) = unused

DATA (H) = unused

 

 

BAUD (L) = unused

DATA (L) = 00H (clear register to receive data)

 

 

EPAREG (H) = 1FH (EPA0_TIME)

PTSCON1 = 00H (receive data on even PTS cycles)

 

 

EPAREG (L) = 42H (EPA0_TIME)

PORTMASK = 08H (P2.3 = RXD)

 

 

PTSCON = 32H (SSIO receive mode)

PORTREG (H) = 1FH (P2_REG)

 

 

PTSCOUNT = 10H (8 data bits x 2)

PORTREG (L) = D4H (P2_REG)

 

 

6.Enable EPA0 interrupt.

Set INT_MASK.2.

7.Load the number of bytes to transmit into the user_defined transmit count register (R_COUNT) and clear the user-defined reception-done flag (RXDDONE).

LD R_COUNT, #16

CLRB RXDDONE

5-48

Page 135
Image 135
Intel 8XC196MD, 8XC196MH, 8XC196MC manual Clrb Rxddone, Ssio Receive Mode PTSCBs