PSoC Designer Manual
PSoC Designer Manual
PSoC Designer Manual
1. Click the File menu and select New Project. 2. Choose any desired name for the project and click OK.
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
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
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
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.
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
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. Set the VC1 clock to SysClk/3. 3. Set the VC2 clock to VC1/16. 4. Set the VC3 Source to VC2 and the VC3 Divider to 250.
PGA
1. In the User Module Catalog (View > User Module Catalog), double click to expand the Amplifiers folder. 2. 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. Select the PGA user module in the Workspace Explorer. 4. 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.
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.
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
7. For the VR_PGA Reference, select analog ground, AGND. 8. For Analog Bus, choose Disable. 9. 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. In User Modules, select the ADCs folder. Right click to place the ADCINC.
2. Select the Single Stage Modulator and select OK. 3. In the Parameters Window, change the Name of the user module to VR_ADC.
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
4. Select Unsigned for the DataFormat. 5. For Resolution, select 8 Bit. 6. For Data Clock, select VC1. 7. 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. For PWM Output select None.
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
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.
3. Set the Clock to VC3. 4. Set Capture to Low. 5. 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. Set CompareOut to None. 7. 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))
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
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. Set the CompareValue to 0. 9. Set the CompareType to Less Than. 10. Set the InterruptType to Terminal Count. 11. Set ClockSync to Sync to SysClk.
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
4. Click Close. 5. In the Pinout window (View > Pinout) click to expand P0[2]. 6. Change the Name to LED2. 7. Set the Select to GlobalOutEven_2. 8. Set the Drive to Strong. 9. 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.
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
//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
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com
// 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. } //end else } //end (VR_ADC_fIsDataAvailable() != 0) } } 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; } 5. Save main.c. 6. Open the lib folder and then the Library Source Files folder. 7. Open the interrupt routine for the LEDFlashTimer user module, LedFlashTimerINT.asm. 8. 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. Save and close the LEDFlashTimerINT.asm file. 10. From the Build menu, select Generate/Build Project.
Trident Techlabs Pvt Ltd S7 Mamanji Center, Thiru Vi Ka Industrial Estate, Guindy, Chennai - 32 Phone No: 044 43358483/84, www.tridenttechlabs.com