热度 16
2013-12-26 11:38
899 次阅读|
0 个评论
How to create a new PSoC project ? ADCINC There are a large number of ADCs available. When choosing an ADC for your own application, consult the ADC Selection Guide (there is a link to it at the beginning of each of the ADC data sheets). This project will use the ADNCINC. Double click to expand the ADCs folder. Double click to expand the ADCINC folder. Right click the Single Stage Modulator and select Place . In the Properties Window , change the name of the user module to VR_ADC. Select Unsigned for the Data Format. For Resolution, select 8 Bit. For Data Clock , select VC1 . For PosInput , select ACB00 . This should have connect 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 . Set the NegInput to ACB00 and the NegInput Gain to Disconnected. This sets the ADC to use a single ended input. For PWM Output, select None. Timer8 The 8-bit timer is used to flash the LED periodically. It uses the interrupt generated by the timer to toggle the LED. Place a Timer8 user module and rename it LEDFlashTimer. 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 to pin to an LED and set the Drive mode on the pin so that it will flash the LED for a single click cycle every time the timer reaches terminal count. 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 the example to show routing of a user module output to a pin. The same technique can be used o route the output of one user module to the input of another. Set the CompareValue to 0 Set the CompareType to Less Than Set the InterruptType to Terminal Count Set the ClockSync to Sync to SysClk. Step 4: Connect the User Modules Each user module has inputs and outputs that can be routed to other user modules and to pins. The output of the VR_PGA user module was routed to the VR_ADC user module in the parameter selection, so to practice routing, you will route the output of the LEDFlashTimer TerminalCountOut to a pin so we can use the signal to flash a LED when the counter reaches terminal count. The main LED from the project will be attached to P0 (port 0, bit 0), and the potentiometer input is on P0 , so you will route this signal to P0 . You ’ ve already routed the TerminalCountOut to row 0 output 2 in the LEDFlashTimer properties. Locate the RO0 (Row_0_Output_2) line in the interconnect view. It is the blue horizontal line that your LEDFlashTimer is attached to. Click the digital interconnect box on the right end of the Row_0_Output_2 line. In the Digital Interconnect dialog, click the top triangle (Row_0_Output_2_Drive_0) and select GlobalOutEven_2 . Click Close . In the Pinout Window (View Pinout) click to expand P0 . Change the Name to LED2 . Set the Select to GlobalOutEven_2 . Set the Drive to Strong . Click to expand P0 (the other pin that will have an LED attached) Change the Name to LED1 Set the Drive to Strong . Click to expand P0 and verify that it is named VR_IN and ensure that Select is set to accept AnalogInput . In the Interconnect view, there is now a line from the TerminalCountOut of the LEDFlashTimer to RO0 , 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. Step 5: Write Firmware The first step in writing the firmware is generating the application. Generating the application creates all of the source files, library files, and headers that are needed to begin writing the firmware. The APIs generated for each of the user modules you have selected are detailed in the user module data sheets associated with each of the user modules. From the Build menu, select Generate/Build Project . In the Application Explorer, double click to expand your project folder.