How to Complete ADC Using PSoC Designer Anthony Recca 11/05/06 Executive Summary: Analog to digital conversion is one way of communicating the desired speed setting to the control circuit of a brushless DC motor This application note will describe the implementation of an ADC user module in PSoC Designer which can be used to program Cypress’s line of PSoC microcontrollers Further, code will be supplied which illustrates how to read the digital value in C language, and to choose a value which can be used to control the duty cycle of a pulse width modulated signal to ultimately control the speed of the motor Keywords: ADC: Analog to Digital Conversion PSoC: Programmable System on Chip PWM: Pulse Width Modulation ADCINCVR: Specific ADC User Module I/O: Input/Output Introduction Cypress has created many user modules for their Designer program which greatly simplifies programming their chips One of these modules provides capability for analog to digital conversion, ADC There are more than ten ADC modules available within PSoC Designer, and which one the user chooses should be based upon their application and the particular chip they are using In the project the author is working on, the CY8C29466 PSoC is used, and the ADCINCVR will be chosen to reduce current draw Overview In the following pages, a short description of the digital/analog blocks associated with the ADCINCVR and the method to add an ADCINCVR in PSoC Designer will be presented Following that will be a discussion on what values should be initially set for the digital and analog blocks used for implementation of this module, and how those values are found Next will be a discussion of the Application Programming Interface, API, functions that are built in to the module and how they are accessed in C code Finally, a short segment of code will be provided to illustrate correct use of the ADCINCVR With the information provided, the reader should be able to implement their own ADCINCVR user module in PSoC Designer ADCINCVR The ADCINCVR user module requires three digital blocks and one analog block The three digital blocks are split into two counters, one is an 8-bit counter which accumulates the number of cycles the output is positive, and the other two blocks are for a 16-bit PWM that measures the integrate time, explained later, and gates the clock to the 8-bit counter The analog block requirement is for the ADC itself Implementation PSoC Designer has two main editors for the programmer, the Application Editor and the Device Editor The Device Editor gives a graphical view of the digital and analog blocks available, input/output ports, buses which can be used to interconnect modules and ports, and allows the user to add modules and modify the parameters for those modules Much more is available in the Device Editor, however those are the important functions pertinent to this discussion To view the Device Editor, click the button labeled A in Figure below To add a user module to the project, click the pull down menu labeled C in Figure 1, choose ADC, and then choose the ADCINCVR from the pull down menu labeled D Clicking button E will add the user module to the list of modules in your project Now you must add the module to your analog and digital blocks, Figure 2, by clicking button G You may select which available digital blocks you wish to place the counter and PWM blocks in to by pressing button F to rotate through the available blocks Interrupts shall not be discussed in this note, however it will be mentioned that Cypress recommends the counter be placed below the PWM digital blocks for interrupt priority as show in Figure The input to the ADCINCVR can be routed to an external pin through the ports available, or to another analog block To route the input to an external pin, the ADCINCVR analog block must be placed in the first column of analog blocks as seen in Figure Looking closely, we can see that Port 2_1 is connected to the input of the analog block of the ADCINCVR Each port is routed to one I/O pin on the chip, this port is routed to pin Figure 1: Toolbar in PSoC Designer Figure 2: Digital Blocks in PSoC Designer Figure 3: Analog blocks and ports (left) in PSoC Designer Parameter Selection Global Resource Parameters When creating a project in PSoC Designer, there are parameters for global resources, and parameters for specific user modules First the global resource parameters pertinent to this application will be discussed Figure shows the global resource parameters The first resource is the power setting and system clock This particular PSoC can be powered with 5V or 3.3V, and the system clock can be chosen to be either 24MHz or 6MHz for either power supply For this example, 5V and 24MHz has been chosen The next parameter is the CPU_Clock and this can be set to the system clock divided by 2^N, with 0 ... the Device Editor, however those are the important functions pertinent to this discussion To view the Device Editor, click the button labeled A in Figure below To add a user module to the project,... provided to illustrate correct use of the ADCINCVR With the information provided, the reader should be able to implement their own ADCINCVR user module in PSoC Designer ADCINCVR The ADCINCVR... connected to the input of the analog block of the ADCINCVR Each port is routed to one I/O pin on the chip, this port is routed to pin Figure 1: Toolbar in PSoC Designer Figure 2: Digital Blocks in PSoC