Using the HC12 Serial Communications Interface

  1. Set baud rate with SBR12-0 of SC0BDH and SC0BDL

    For example, for 9600 baud:

  2. Enable transmitter and receiver (TE and RE bits of SC0CR2)
  3. Select 8-bit or 9-bit mode (M bit of SC0CR1)
  4. If using parity, enable parity (PE bit of SC0CR1) and choose odd or even (PT bit of SC0CR1)
  5. If using interrupts enable TIE or RIE interrupt in SC0CR2

To transmit data:

  1. If sending 9 bit data, write T8 bit to SC0DRH
  2. Write data to SC0DRL
  3. Wait for transmit data register empty TDRE bit of SC0SR1, or transmit interrupt if enabled.
  4. Send next data word.

To receive data:

  1. Wait for receive data register full RDRF bit of SC0CR1, or for receive interrupt
  2. Read data from SC0DRL (if receiving 9-bit data, get ninth bit from R8 bit of SC0DRH)
  3. If desired check for overrun error, noise flag, framing error, or parity error.

If both receive and transmit interrupts enabled need to check in interrupt service routine to see if transmit interrupt or receive interrupt is active.

Bill Rison
Wed Apr 14 17:26:06 MDT 1999