Exploring STC 8051 Microcontrollers – Coding
Communication Hardware Overview
STC8A8K64S4A12 packs all kinds of common communication hardware peripheral that most modern microcontrollers can offer. The following are available in STC8A8K64S4A12’s arsenal:
As always, we also have options for software-based communications. Using some coding, we can implement software-based SPI, I2C and other forms of communications. One wire communication is a good example. One wire communication is fully implemented in software. Using a combination of hardware and software, we can also implement methods to decode IR communication.
Though software methods will rarely be needed, these methods allow us to understand the working principle of different communication methods and in this way build confidence for coding devices that do not follow standard I2C, SPI or UART methods. The downside of software communications is their relative processing speed when compared with their hardware counterparts because software-based communications are made virtually in codes rather than in physical hardware.
I won’t be discussing much about the software techniques because in all of my past tutorials, I have been discussing about them briefly and most of these stuffs are mere confirmation of implementation and repetition.
UART offers long-distance serial communication and can also be employed for simple SPI-like serial and industry-standard RS-485 communications. STC8A8K64S4A12 has four UART hardware with independent interrupts. UART1 is the most advanced UART of all. All UART hardware peripheral need a timer for baud rate generation. Timer 2 is common to all of these UARTs and so it is wise to leave it for UARTs. All of these UART have multiple alternative pins associated with them. These pin mapping is summarized below:
I2C hardware available in STC8A8K64S4A12 is very simple but it offers lot of flexibilities. The I2C block can be used in both I2C master or slave roles. Just like UART it has lot of alternative pin pair options as the table below shows.
SPI hardware is also fully implemented in STC8A8K64S4A12. Using the SPI hardware is very simple and like other communication peripherals, we have options to use various alternative GPIO pin groups. Both SPI and I2C blocks are fully independent blocks unlike UARTs as UART blocks are dependent on internal hardware timers.