In addition, we suggest the following instruments:
The following programs must be installed on your development work station:
The Universal Asynchronous Receiver/Transmitter (UART) is an electronic device that converts parallel data to a serial data stream. Early microprocessors used independent integrated circuits to perform the conversion and frame the data stream with a start and stop bit. Currently, a vast majority of microprocessors have internal UART functionality, resulting in reduced system cost and complexity. The UART is capable of full-duplex operation, meaning simultaneously receiving and transmitting data. UARTs are generally constrained to a single peer-to-peer paired devices commonly called point-to-point communications.
Asynchronous communication is the transmission of data between two devices that are not synchronized with one another via a clocking mechanism or other technique. The term asynchronous implies the sender can initiate data transmission at any time, and the receiver must be ready to accept information when it arrives. The two devices must be operating at, or nearly equal to, the same clock frequency and are resynchronized by a START bit sent along with the data.
Text messages will be sent to the UART serial port whenever a change in switch settings is detected and the action will be reported to a computer terminal. Whenever a text string is entered on the computer terminal, it will be displayed on the Basys MX3 LCD.
Asynchronous communications is a serial data protocol that has been in use for many years. Normally eight bits of data are transmitted between handshaking characters to allow the clocks of transmitting and receiving devices to be synchronized. There are other less commonly used modes that can send 5, 6, or 7 bits of data. Each byte of data is framed by a start bit and a stop bit. A symbol is defined as a start, data, parity, or stop bit. It is common to define common to define communications speed as bits per second. The bit rate is defined as the inverse of the period of a unit symbol. Although the common standard bit rates are 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, and 115200, communications is possible at any rate provided that the sender and receiver use the same rate. For most asynchronous communications, the term “baud” is commonly used interchangeably with the term “bit rate.”
1. Connect the Basys MX3 UART USB port to one of the work station’s USB ports.
2. If the workstation is running a Windows OS, open the “Control Panel” followed by opening the “Device Manager” window. If you do not have administrator privileges, you will see the window shown in Fig. 8.1. Click on the OK box to continue. Administrative privileges are not required to view the settings.
Figure 8.1. The device manager window showing you do not have administrator privileges.
3. Expand the tab called Ports (COM & LPT) as shown in Fig. 8.2.
Figure 8.2. PC device manager window.
4. Note the USB Serial Port COM assignment.
5. Open the terminal emulation program on your workstation. Configure the terminal program for 19200 BAUD and ODD parity. The screen shown in Fig. A.4 of Appendix 1 is for the PuTTY terminal emulation program.
6. Launch a new Microchip MPLAB X project called LAB4b. Add the config_bits.h file to the project.
7. Develop the following UART interface functions: Note that the numeral “4” in the function names indicate that the Basys MX3 uses the PIC32MX370 UART 4. All receive functions are to be non-blocking.
uart4Init(); // 19200 Baud, ODD parity (int) ch = uart4Getc(); // ch = -1 if no data has been received (int) len = uart4Gets(char *str); // len = -1 if no data has been received uart4Puc(char ch);< uart4Puts(char *str);
8. Develop the PIC32 application that meets the requirements in section 8.1.
Figure 8.3. Handshaking pins and data bit zero for single character write to the LCD.
1. What is the effective data rate of the UART? (Remember to include the period of the stop signal that cannot be measured in testing step 4a.)
2. Based on the data collected in step 4 parts 4.4 and 4.5 of the testing procedure, what is the effective character display rate in characters per second?
3. Based on the data collected in step 4 part 4.6, how much does moving the cursor from line 1 to line 2 slow down the LCD character display rate? Justify your answer.
Figure A.1. PIC32MX370 to FT232RQR IC schematic diagram.
Figure A.2. UART USB connector on the Basys MX3.
Figure A.3. PuTTy screen shot generating LCD display.
Figure A.4. PuTTY screen shot of serial configuration for 19200 BAUD and ODD parity.
If when compiling your project you see an error like “ld.exe Error: A heap is required, but has not been specified,” this is because you need to specify a heap size by setting “Run” →“Set Project Configuration” → “Customize…”. Go to the “xc32-ld” category (under “XC32 (Global Options)”) → “Heap size (bytes)” to “0” The configuration window should look like Fig. B.1. Click on the “Apply” button followed by clicking on the “OK” button. See http://microchip.wikidot.com/mplabx:creating-a-heap.
Figure B.1. Allocating Heap size.