Chapter 9: Communications
* Introduction
* 9.1 USART and Software UART
* 9.2 SPI and Software SPI
* 9.3 I2C and Software I2C
* 9.4 Manchester Code
* 9.5 RS485
* 9.6 OneWire
* 9.7 CAN & CANSPI
Introduction
When you start writing real-life programs for PIC, you may soon find yourself having a “lack of space” feeling, that you need just a few more pins and a couple of dozens of bytes to do the job. You might want to solve this problem by transferring to bigger PIC, and the problem will be solved… for a little while. Or, you just happened to have found a beautiful, brand-new humidity sensor that does “all the job by itself”, leaving you just to connect it to PIC and pick up the data… That is, if you know how to do that. If you’ve come up with these or similar problems, it really is time for you to teach your PIC and yourself some communication lessons.
There are many ways for two machines to communicate these days, and PICs are generally well equipped for the task. Depending on the job to be done, data exchange – what communication basically is – can be done in a fairly simple manner, such as the SPI communication, but can extend to an entire network of various devices – MCUs, PCs, cameras, “intelligent” sensors, etc. With increased demands, rules of device behaviour must encompass a wider set of possible scenarios and therefore protocols dramatically grow in complexity (CAN, for instance).
Consider your needs carefully before jumping to CAN-driven solutions. There are different communication methods, offering lot of possibilities at varying levels of complexity. The rule of “sacred simplicity” remains here as well: do not use more complex communication tools than you really need to!
In this chapter, you’ll get yourself acquainted with various means of communication that are being used by the PIC MCUs, and the ways to access and extend them from the BASIC programming language. You may have already noticed that some of the communication devices also have their software counterparts, meaning you can have the same communication functionality that is achieved through a set of software routines that can be used through the BASIC programming language. You should be using software communication when you have utilized all the real (hardware) communication resouces but still need an extra communication line. Read the rest of this entry »
Tags: BASIC, component, errorCount, ErrorFlag, IdleCount, LCD, Manchester, microcontroller, mikroElektronika, PIC, PORTB, PORTD, receiver, RRX, UART