Bailey O.H.Embedded systems.Desktop integration.2005
.pdf
390 |
Chapter 9 / The PIC Prototype |
|
|
The TTL Serial Routine
The only remaining communications routine to implement is the TTL serial interface for the 16C745 device. I need to again stress that the compiler suite for this device is different from the dsPIC, so we will be using different tools. There are differences in the number of pins and functionality of the different PIC processors. This time we will show how to create two TTL serial ports on Port B and handle SUB I/O using PicBasic Pro. Listing 9-8, when used in conjunction with the HIDmaker files and the USB init and I/O files from Microchip, illustrates how to set up our two serial ports and send a USB message.
Listing 9-8
//Chapter 9 USB & Serial Port Test
//Embedded Systems, Desktop Integration
//Copyright 2004, Oliver H. Bailey
//
//This program illustrates how USB and serial
//code can co-exist.
//
//First we define the I/O pins to use on the 16C745
//For this example we will assign two TTL serial
//ports to the pins on port RB. The following code
//will send the hello world string to our first
//defined TTL port.
//
//This code works in conjunction with the HIDmaker code defined
//earlier and the endpoint descriptors created by HIDmaker.
//This program is also dependent on the USB initialization,
//and I/O assembler routines from Microchip
//Declare Byte Array for Message
Msg var byte[11]
// Assign String to Array Msg[0] = "H"
Msg[1] = "e"
392 |
Chapter 9 / The PIC Prototype |
|
|
The Finished Circuit
Unlike the BASIC Stamp, there are a few more components required for the PIC version. To start with, we have to supply a clock source. The dsPIC can be controlled through an external or internal clock source. For this circuit we will use an external clock because it provides a higher speed. Following is the parts list for the dsPIC interface board:
One 24 mHz crystal oscillator
One 2.2 K ¼-watt resistor
Two 4.7 K ¼-watt resistors
One red power LED
One 7805 voltage regulator
One normally open push button switch
One 1N914 diode
One 2-pole terminal strip
Two 3-pole terminal strips
Three 3-pole terminal strips
One dsPIC 30F2010 microcontroller
Since the dsPIC is a relatively new product, please check the current data sheet at www.microchip.com for the latest information on recommended clock crystals. The dsPIC 30F2010 can be purchased from Microchip, DigiKey, or Jameco, as can the rest of these parts. The terminal strips are standard 0.1" center-to-cen- ter and are also available from the above sources. In earlier parts list I have listed Radio Shack as a source. While Radio Shack does carry the resistors, diodes, and LEDs, they don’t have a wide selection of terminal strips, which is why they are not listed here. DigiKey is the best source and has all of the above components.
Chapter 9 / The PIC Prototype |
393 |
|
|
Because of the increased complexity of our circuit, this time we will need to make a two-sided circuit board. If you wish to purchase the board instead, please visit www.time-lines.com and follow the Embedded Systems 1 Component link. If you choose to make your own boards, the schematics follow.
Chapter 9
Figure 9-18
This page intentionally left blank.
398 |
Chapter 10 / The PSoC Prototype |
|
|
through software using several different steps. The PSoC chip can actually be several different devices within the same chip that interact together or act as separate components. In addition the PSoC can be reprogrammed on the fly, allowing each device (or block) within the PSoC to have several personalities depending on event triggers or interrupts. This feature is what makes the PSoC different from the other microcontrollers we’ve worked with so far. This chapter will not cover on-the-fly programming because of the subject scope; instead we will implement functions comparable to the PIC and BASIC Stamp equivalents. For more information on the advanced features of the PsoC, visit the Cypress web site at www.cypress.com or my site at www.time-lines.com.
Developing PsoC-based hardware is heavily dependent on software, namely the PSoC Designer. Everything from designing PSoC hardware blocks and writing source code to debugging in-circuit emulation is handled by the PSoC Designer. The PSoC Designer provides a selection of “canned” hardware functions that can be plugged in by simply dragging and dropping the function onto the design screen. Using the Designer the engineer can define which pins provide associated functions. As different functions are added, how different hardware functions can interact through the use of registers and memory can be defined. Later in this chapter we will work through an actual design session for our thermostat.
Comparing the PIC and the PSoC
At first glance both of these microcontrollers seem identical. Both allow the engineer to design using a building block approach. Both allow analog and digital signals to be processed and both come with similar amounts of RAM and even similar packages. Even so, there are many differences between these devices.
