English
Language : 

MC81F4332 Datasheet, PDF (148/198 Pages) Finechips – ABOV SEMICONDUCTOR 8-BIT SINGLE-CHIP MICROCONTROLLERS
MC81F4x16
23.2 Procedure
To program the SIO module, follow these basic steps:
1. Configure the I/O pins at port (SCK/SI/SO) by loading the appropriate value to the R0CONM,
R0CONH register if necessary.
- If one side uses a internal clock, the other side must use a external clock.
- Note that, if the external clock is used, you must set the SCK port as an input mode.
2. Set SIOPS register with proper pre-scale value.
3. Load an 8-bit value to the SIOCR to properly configure the serial I/O module. In this operation,
SIOP [SIOCR.2] bit must be set to "1" to enable the data shifter.
4. For interrupt generation, set the SIO interrupt enable bit, SIOIE to "1".
5. Data transmit and receiving are occurred at the same time. So before start the shift operation, you
must set the SIODAT with what you want to transmit.
- When SIOM [SIOCR.3] bit is 0, it does not transmit a data.
6. When set SIOCR.1 to 1, the shift operation starts.
- With internal clock: shift operation is started right after SIOCR.1 is set.
- With external clock: shift operation is started when the master starts the operation.
7. When the shift operation (transmit/receive) is completed, the SIO interrupt request flag bit, SIOIR is
set to "1" and SIO interrupt request is generated.
- Don‟t forget to set the SIOCR.1 bit by 1, to receive next SIO data if want.
When the SIO interrupt sub-routine is serviced, the SIO interrupt request flag bit, SIOIR, is cleared
automatically.
148
October 19, 2009 Ver.1.35