Beruflich Dokumente
Kultur Dokumente
Installation
PSoC Designer is available for download at http://www.cypress.com/go/designer. You can also download an ISO image to create an installation CD. Each Starter Kit also includes an installation CD. If you need help installing PSoC Designer, call Cypress Support at 1-800-541-4736 and select 8. After installation of PSoC Designer you can access PSoC Designer from the Start menu. To start PSoC Designer, click Start > All Programs > Cypress > PSoC Designer 5.1 > PSoC Designer 5.1.
This guide helps you to program a PSoC device through a quick start project using the PSoC evaluation boards such as the CY3210-PSoCEval1. The project reads the voltage from a potentiometer and sets the LED to off, on, or blinking depending on the voltage level. When you are finished with this guide you will be familiar with the entire design process. PSoC Designer Quick Start Guide Doc. No. 001-66310 Rev. ** 1
Your project opens in the Device Editor Chip-Level view. The default view has secondary windows that show all kinds of information about your project. You can move, resize, close, and arrange all of these secondary windows to suit your preferences. The View menu contains the available windows.
Global Resources
Global Resources are those shared by all user modules in a particular configuration. The IDE Guide (Help > Documentation) contains a complete reference on the effect of each of the Global Resources.
1.
Set the CPU Clock to SysClk/1. Since the Power Setting is at the default of 5.0 V operation and a SysClk of 24 MHz, the CPU will also run at 24 MHz.
2. 3. 4.
Set the VC1 clock to SysClk/3. Set the VC2 clock to VC1/16. Set the VC3 Source to VC2 and the VC3 Divider to 250.
PGA
1. 2. In the User Module Catalog (View > User Module Catalog), double click to expand the Amplifiers folder. Right-click PGA and select Place. The PGA is placed in the first available analog block. The default placement of the user module is sufficient. 3. 4. Select the PGA user module in the Workspace Explorer. In the Workspace Explorer window, right click on PGA_1 > Properties. The Parameters window for PGA_1 opens. Change the name of the user module to VR_PGA.
Note that the user module name in the Chip-Level view updates with the new name. Right click in an open area of the Interconnect view and select Zoom In to get a close up view of the resources. Press [Alt] and click the mouse to pan the window. Right click again and select Original View to restore the original view. 5. Set the Gain for VR_PGA to 1.000. The PGA is used to buffer the input of the potentiometer, so the Gain is 1. 6. Set the Input to AnalogColumn_InputMUX_0. The input for the PGA will come from the potentiometer routed from a pin to the AnalogColumn_InputMUX_0. By default, the AnalogColumn_InputMUX_0 is routed from P0[1]. You can click the mux and select one of four pins, but the default is works for this purpose. 7. 8. 9. For the VR_PGA Reference, select analog ground, AGND. For Analog Bus, choose Disable. On the diagram, click Port_0_1.
ADCINC
There are many ADCs available. When choosing an ADC for your application, consult the ADC Selection Guide (there is a link to it at the beginning of each of the ADC datasheets). This project will use the ADCINC. 1. In User Modules, select the ADCs folder. Right click to place the ADCINC.
2. 3.
Select the Single Stage Modulator and select OK. In the Parameters Window, change the Name of the user module to VR_ADC.
4. 5. 6. 7.
Select Unsigned for the DataFormat. For Resolution, select 8 Bit. For Data Clock, select VC1. For PosInput, select ACB00. This connects the output of the VR_PGA GAIN block to the PosInput of the VR_ADC. Check the diagram to make sure that there is a line connecting them. If you are using a chip that has a different configuration of analog blocks than the CY8C29466-24PXI used in the example, choose the block that contains the VR_PGA GAIN block in place of ACB00.
8.
Set the NegInput to ACB00 and the NegInput Gain to Disconnected. This sets the ADC to use a single-ended input.
9.
Timer8
The 8-bit timer is used to flash the LED periodically. It uses the interrupt generated by the timer to toggle the LED.
1.
In User Modules, select the Timers folder, and place a Timer8 user module.
2.
3. 4. 5.
Set the Clock to VC3. Set Capture to Low. Set TerminalCountOut to Row_0_Output_2. You will route the Terminal Count output to a pin so you can get some practice routing resources in PSoC Designer. You will connect the pin to an LED and set the Drive mode on the pin so that it will flash the LED for a single clock cycle every time the timer reaches terminal count.
6. 7.
Set CompareOut to None. Set the Period to 250. The flash rate of the LED will be 1/4 second: (24 MHz 3 (VC1) 16 (VC2) 250 (VC3 Divider) 250 (Period)) The timer will hit terminal count 8 times per second and each of these terminal counts toggles the LED. The other example project uses the SleepTimer user module rather than the Timer8. The SleepTimer is configurable down to 1 Hz without using the clock dividers. The Timer8 was used in this example to show routing of a user module output to a pin. The same technique can be used to route the output of one user module to the input of another.
8. 9.
10. Set the InterruptType to Terminal Count. 11. Set ClockSync to Sync to SysClk.
4. 5. 6. 7. 8. 9.
Click Close. In the Pinout window (View > Pinout) click to expand P0[2]. Change the Name to LED2. Set the Select to GlobalOutEven_2. Set the Drive to Strong. Click OK.
10. Click to expand P0[0] (the other pin that will have an LED attached). 11. Change the Name to LED1. 12. Set the Drive to Strong. 13. Click OK. 14. Click to expand P0[1] and verify that it is set to accept AnalogInput and is named VR_IN. In the Interconnect view, there is now a line from the TerminalCountOut of the LEDFlashTimer to RO0[2], then to GlobalOutEven_2, and finally to Port_0_2. You have successfully routed the terminal count of your timer user module to a pin and configured the pins for the inputs and outputs attached to them.
unsigned char ucVR_ADCResult; //This global variable holds the converted output of the potentiometer (VR). void main(void) { M8C_EnableGInt; LEDFlashTimer_Start();
VR_PGA_Start(VR_PGA_HIGHPOWER); //Performs all required initialization for the PGA User Module and sets the power //level for the PGA to high power (VR_PGA_HIGHPOWER). VR_ADC_Start(VR_ADC_HIGHPOWER); //Performs all required initialization for the VR_ADC User Module //and sets the power level to high power. VR_ADC_GetSamples(0); //Sets the VR_ADC to run continuously by providing a 0 in the paramater list. while(1) //infinte loop. { if (VR_ADC_fIsDataAvailable() != 0) //This function checks the availability of sampled data. The function returns //a non-zero value if data has been converted and is ready to read. { ucVR_ADCResult = VR_ADC_bClearFlagGetData(); //This function clears the data ready flag and gets converted data as an // unsigned char and stores it in the variable ucVR_ADCResult. //This function also checks to see that data-flag is still reset. //If not the data is retrieved again. This makes sure that the ADC interrupt //routine did not update the answer while it was being collected. if (ucVR_ADCResult <= 85 )
//Test to see if the potentiometer is less than 1/3 of the way up //its 8-bit scale. { LEDFlashTimer_DisableInt(); //Disabling the Interrupt for the Timer stops the blinking LED1_PORT &= LED1_OFF; //Turns the LED Off } //end (ucVR_ADCResult <= 85) else if (ucVR_ADCResult <= 170) // Test to see if the potentiometer is less than 2/3 of the way up //its 8-bit scale. { LEDFlashTimer_EnableInt(); //Flashes the LED } // end (ucVR_ADCResult <= 170) else // Don't need to test the top third. { LEDFlashTimer_DisableInt(); //Disabling the Interrupt for the Timer stops the blinking LED1_PORT |= LED1_ON; //Turn on LED1 by setting Bit 0 of Port 0 to high. } } } } void LEDFlashTimer_ISR_C(void) { //Read Port0 and XOR it with 0x01 to change the status from On to Off and vice-versa. PRT0DR ^= 0x01; } //end else //end (VR_ADC_fIsDataAvailable() != 0)
5. 6. 7. 8.
Save main.c. Open the lib folder and then the Library Source Files folder. Open the interrupt routine for the LEDFlashTimer user module, LedFlashTimerINT.asm. Insert the following line after the @PSoC_UserCode_BODY@ banner in the _LEDFlashTimer_ISR section.
ljmp _LEDFlashTimer_ISR_C ; jump to the ISR written in C in main.c
9.
10. From the Build menu, select Generate/Build Project. You are now ready to program your PSoC device.
2. 3. 4.
Place your PSoC chip into the evaluation board, and plug your programmer into the Target ISSP connector. Click the Program button, and the program is loaded into your PSoC chip. Unplug the programmer from the Target ISSP connector, and connect wires on the evaluation boards breadboard(s) to route the signals to their respective pins. (Wire connections are performed after programming to prevent conflicts with the PSoC programmer.) Press the Target Reset button. Check to see that the program works as desired by adjusting the input voltage to 1 V, 2 V and 4 V (you can use a DVM monitor to assist), and observing the LED response. To observe the blinking LED state, which is expected at 2 V, make sure to maintain 2 V for at least 1 second.
5. 6.
2010 Cypress Semiconductor Corporation. PSoC Designer is a trademark and PSoC is a registered trademark of Cypress Semiconductor Corporation. All rights reserved. All trademarks or registered trademarks referenced herein are the properties of their respective owners.
10