Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Bailey O.H.Embedded systems.Desktop integration.2005

.pdf
Скачиваний:
73
Добавлен:
23.08.2013
Размер:
9.53 Mб
Скачать

430

Chapter 10 / The PSoC Prototype

 

 

Figure 10-18

The EZ-USB development kit also includes a book on the USB bus, a technical reference manual for the kit, a getting started guide, USB cable, RS-232 cable, and a CD that contains all the information, data sheets, application notes, and Keil C compiler. The compiler uses a small memory model, so if you have a bigger project you may want to invest in the full version of the compiler. Unlike the PSoC, the EZ-USB development software is installed by default to the \Cypress\USB\ folder. There are several example projects in the \Examples\EzUsb folder.

There is a lot to learn to use EZ-USB to its fullest potential so we will work through a short project that illustrates how to use the developers kit. All of the project related files can be downloaded from www.wordware.com/files/embsys or www.time-lines.com. Let’s get started.

Chapter 10 / The PSoC Prototype

431

 

 

 

 

1. The first step is to install the software from the EZ-USB CD.

 

You can insert the CD or download the zip file from the

 

 

Cypress web site. The most recent version supports several

 

EZ-USB boards. During the software installation process the

 

compiler and device driver will be installed for Windows.

 

 

Some versions of Linux have built-in support for the EZ-USB

 

chip, while others require a separate device driver file. The

 

latest information is available in the downloaded companion

 

files. This allows me to keep these projects current while at

 

the same time keeping the book current.

 

 

2. Once the software is installed, reboot the system if

 

 

prompted. Usually Windows versions prior to 2000 will

 

 

require a reboot. Next, plug in the USB cable and connect the

 

EZ-USB development board. A red light in the lower-left cor-

 

ner of the board will come on while the device driver is being

 

located. Eventually you should be prompted to press the Fin-

 

ish button to complete the installation. Once the driver is

 

 

installed correctly, a green light on the development board

 

will become lit.

 

 

If the installation went properly you can hold down the Reset

10

button on the EZ-USB development board for a few seconds.

Chapter

 

 

 

This will disconnect the board and unload the driver. Releasing the Reset button will reload the driver and re-attach the board. The intelligence of this board lies in the chip directly below the USB connector at the top of the board. The board has four additional buttons, several dip switches and jumpers, two serial ports, and a seven-segment LED display. The headers along both sides extend the I/O pins to the prototype board. To debug a program we need to also install an RS-232 cable between a COM port on the PC and SIO-1 on the EZ-USB board. SIO-1 is the nine-pin connector at the top-right side of the board next to the USB connector.

432Chapter 10 / The PSoC Prototype

3.If you have the EZ-USB board connected via the USB cable, disconnect it now. Next, go to Start | Cypress | USB | EZ-USB Control Panel. The following screen should be displayed.

Figure 10-19

4.This program allows the developer to interrogate, control, and even download new software to the EZ-USB. Click the Open All button. For each EZ-USB device detected and working, a child window will appear. The window title will be the EZ-USB device number. In Figure 10-19, we have one EZ-USB device attached, titled Ezusb-0. Within the child window a GetPipeInfo command was executed and the results appear in the open area of the child window. The interface size will be displayed as the last line of information for each child window. In this case the interface size is 16.

Chapter 10 / The PSoC Prototype

433

 

 

The Clear button clears the message display of the associated EZ-USB device. To make sure the device is working properly, locate the LoadMon button and click on it with the mouse. You will see a large number of columns of hex data scroll through the message display; at the very end will be Toggle 8051 Reset, which is the final message that means the EZ-USB processor has been reset and is waiting for the next command. If you press the Reset button on the EZ-USB board, nothing happens because the EZ-USB is still in a reset condition. Press the Send button next to the current command (GetPipeInfo) and the interface size will again be returned. Now if you press the Reset button on the EZ-USB board the green light will go out until it is released. This means the EZ-USB is again running.

The second row of buttons in the control windows for Ezusb-0 request specific information about the device. Pressing one of these buttons will return the current contents of the request. The buttons along the left side also request specific types of device information. Some of these buttons will cause the EZ-USB to suspend operations until another request is sent or the Run button is pressed. For example, if you press the Vend Req button, nothing happens until the Reset button on the EZ-USB board is pressed; then the button on the display pops back up.

5.The EZ-USB Control Panel can also be used to download a new program to the board. As an example of this, press the

Download button and select the \Cypress\USB\Examples\EzUsb\dev_io\dev_io.hex file. The following figure shows the screen that is displayed.

Chapter 10

434

Chapter 10 / The PSoC Prototype

 

 

Figure 10-20

During the download each message from both the host and client is displayed in order. In Figure 10-20, after each block of data a Vendor Request message is sent. After the download is completed the EZ-USB is reset and the seven-segment display displays a zero. The four buttons below the display will take the following actions from left to right: Zero set, decrement, increment, and set to Hex F. You will notice the green light on the EZ-USB board is off. Pressing it once will stop the program that manages the buttons and display and will turn the green LED back on. Now pressing the buttons has no effect.

The seven-segment display will remain lit until the power is removed and reapplied to the EZ-USB board. Unplug the USB cable, wait 10 seconds, and plug it back in to turn the seven-seg- ment display off again. As you can see, the Control Panel provides the developer with some access to EZ-USB development functions from within the Windows operating system.

Chapter 10 / The PSoC Prototype

435

 

 

1.Now it’s time to start the compiler and test the debug connection. The first step in this process is to start the Keil uVision2 development IDE. There is a desktop shortcut installed along with the EZ-USB development software, so let’s double-click it now. In a few seconds you will see the main IDE screen that looks similar to the following figure.

Figure 10-21

2.We need to load the dev_io project file located in the same directory as the hex file loaded before. Select Project | Open Project and choose dev_io project file. When the project has loaded, you will see a screen similar to the following.

Chapter 10

436

Chapter 10 / The PSoC Prototype

 

 

Figure 10-22

3.Before we can debug we need to make certain the PC Comm Port Settings and Baud rate options are correctly set. To check these, select Project | Options for [target 1] menu. The Options window will be displayed. Press the Debug tab and then choose settings as shown in Figure 10-23.

Figure 10-23

Chapter 10 / The PSoC Prototype

437

 

 

The default COM port is 2 and the baud rate defaults to 38400. If you’re using the EZ-USB full speed board, the baud rate needs to be changed to 19200. If your system has only one COM port, set the port to COM 1. If these settings are incorrect, the debugger will not work and it will be unclear exactly what is wrong.

4.The next step is to initialize the debugger. This is done by selecting the Debug | Start/Stop Debugger menu item. This will initialize the debugger and connect to the EZ-USB debugging monitor. When fully initialized your screen will look similar to Figure 10-24.

Chapter 10

Figure 10-24

5.Before we begin our debug session let’s make the debug commands available from the main display. To do this, select View | Debug Toolbar and make sure there is a check next to it. If it isn’t checked, select the Debug toolbar; otherwise just exit this menu.

We are now ready to start a debug session. We can use the mouse and click the debug commands, which are on the

438

Chapter 10 / The PSoC Prototype

 

 

second toolbar on the far left side of the screen or the following function keys map to debug commands. They are:

F5 — Run from current instruction

F11 — Step into next subroutine

F10 — Step over next subroutine

Pressing the F11 key will make the yellow arrow increment to the next line. Pressing the F10 key will increment to the next line or, if the next line is a subroutine the subroutine will be executed and the debug cursor will stop at the next instruction after the subroutine has exited. Press the F10 key a couple of times and watch the instruction pointer increment. You will notice that a green bar moves in the Register display on the far left side of the screen. As the instructions change the register values, the display is changed to reflect their current contents.

6.Let’s execute the program full speed. To do so, press F5. The display doesn’t update when the program is running at full speed so the instruction pointer and register display is no longer updated. When the program is running, pressing the Escape key will reset the program. That concludes our tour of the development IDE and debugger.

The EZ-USB UARTs

Thus far we haven’t mentioned the TTL serial ports on the EZ-USB chip. The EZ-USB has two built-in TTL UARTs for communicating with the outside world. The serial ports on the EZ-USB are very similar to the PSoC with a few exceptions. Either a timer or system clock with a divisor can be used as the baud rate generator. There are four modes of configuring the UARTs with respect to data size, start bit, stop bit, and parity. We will also need to handle handshaking manually just as we did with the PSoC. This is a simple task of changing a line or pin state to indicate we are ready to receive data and checking the state of

Chapter 10 / The PSoC Prototype

439

 

 

the handshake line before sending data to a desktop system. In the listing files you will find both listings for using the system clock and a timer. Both methods have their advantages and disadvantages.

The Ethernet Interface

This is the final topic of discussion for the hardware chapters. For development purposes, we will use the SIO-0 port on the EZ-USB and connect that to the serial board on the NetBurner board. All that is needed is a standard RS-232 cable between the two. Once testing is complete we can use the TTL version of the RS-232 interface at both the NetBurner and EZ-USB sides.

The NetBurner SB72 Board

The NetBurner hardware and the TCP/IP interface are covered in detail in Chapter 8. In this chapter we will use the same hardware, but instead of using TCP/IP we will use the User Datagram Protocol, or UDP. Unlike TCP/IP, this protocol is connectionless. There is no dedicated connection between the PSoC and the desktop machine. UDP does not guarantee that the data sent will ever be received by anyone. If we were broadcasting across the Internet we would have reason for concern when using the UDP protocol; however, using that protocol on a LAN is pretty reliable. In fact, using UDP in a LAN environment has some distinct advantages. For example, using UDP we can broadcast the temperature to many computers at once much the same way a radio station broadcasts music. So if our thermostat is used in a cold storage facility, this would allow anyone with network access to “dial-in” to the thermostat and get real-time temperature and temperature alarm data. When it comes to controlling thermostat functions we need to limit that ability to a chosen few. This greatly reduces the possibility of tampering by unauthorized

Chapter 10

Соседние файлы в предмете Электротехника