SPECIAL PROJECT ON ON PSoC : Development Analysis & Options For Future Development Prepared under the supervision of Dr M.K.
Abstract This report presents the methodology used in preparation of a handbook and lab manual for Programmable System on Chip. This report must be read in conjunction with the PSoC Hand Book and Lab Manual which is attached separately.
Acknowledgement No part of this work would have been possible without the active support and guidance of Dr M.K. Deshmukh. His commitment to ensuring relevancy of work and ease of use for future users made me choose this as topic for the special project. I sincerely thank the encouragement by Mr M T Abhilash, Lab-in-charge, PSoC Lab, BITS Pilani Goa Campus who has allowed students like us access to lab facilities often at odd hours.
Table of Contents Cover page Abstract Keywords Contents i ii ii iii 1. Introduction ` 2. Contents of Work Done 5 7 2.1 System Overview 2.2 Basic Functionality 2.3 Comparison with dsPIC 2.4 Digital & Analog Functional Blocks 2.5 SMP, MAC, Decimator 2.6 I2C Controller, Interrupt Controller, Address Space 2.7 Basic Module Description 2.8 Advanced Module Description 2.9 Specific Projects 2.9.1 Blinking LEDs 2.9.2 Controlling Blinking LEDs 2.9.3 LCD Interfacing 2.9.4 Digital Sine Wave Generation 2.
1. Introduction PSoC (Programmable System-on-Chip) is a family of mixed-signal arrays first made by Cypress MicroSystems (CMS), a subsidiary of Cypress Semiconductors. This features a microcontroller and configurable integrated analog and digital peripherals. PSoC is a software configured, mixed-signal array with a built-in MCU core. The core is a Cypress proprietary, 8-bit Harvard architecture design called the M8C.
Again, Cypress Semiconductor itself prefers users to ignore the component based specification of systems and define only inputs/outputs and the required transfer functions using PSoC Express while leaving the actual component selection, specification and use to the software. This aspect is explored in considerable detail using the newly acquired latest PSoC First Touch® Starter Kit.
2. Contents of Work Done 1 Introduction 2 Basic Module Description 3 Advanced Module Description 4 Specific Projects - 1. 2. 3. 4. • • • • • • Comparison with dsPIC System Overview Basic Functionalities Digital & Analog Functional Blocks SMP, MAC, Decimator I2C Controller, Interrupt Controller, Address Space 1. ADC 2. Amplifiers 3. Counters 4. DAC 5. Filters 6. PWM 7. Random Sequence Generators (PRS8,PRS16) 8.
3. Survey of Application Notes and Categorization: An attempt has been made here to enlist the relevant existing application notes written until August, 2007 and explore its relationship to BITS Course Work. The results of this study have been enumerated here for quick reference. All of these applications can be used as Lab Oriented, Study Oriented, Computer Oriented Projects.
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number Description Relevance to Course AN2408 CapSense - Migrating from CSR to CSD AN2407 USB and CapSense - PC Compatible USB CapSense Matrix Keyboard Power - PSoC® IO Power Structure - Determining VOH and VOL at Partial Load AN2405 AN2401 AN2399 Communication - Using the USBUART User Module Communication - Software Implementation of Universal Asynchronous Transmitter Author Ted Tsui Michael Macovetskyi, Rus
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number AN2392 Description Relevance to Course AN2389 Multi-Context Switch Event Kernel Display and USB - Graphic OLED Display Demonstration Board With USB Interface AN2388 USB - Voice Player with ADPCM Decoder AN2385 Phase Controller with Current Limit Using the MAC (multiply/accumulate) to compute scalar product of vectors Migrate from register oriented microprocessors to PSoC Universal Wide-Range Signal Gener
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number Description Relevance to Course Author Associated Application Notes Systems AN2357 AN2356 Power - Multi-Channel Fan Speed Control System User Interface - Graphics Library for OSRAM's OLED Displays Volodymyr Sokil Valeriy Kyrynyuk AN2355 Capacitance Sensing - Calibrating CapSense with the CSR User Module Darrin Vallis AN2354 Power Management - Practical Application of the PSoC(R) Sleep Timer Darrin V
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number AN2339 AN2338 AN2336 AN2335 AN2334 AN2333 AN2332 AN2330 AN2329 Description Relevance to Course Design Aids - Storing Calibration Factors into Flash Memory Within a PSoC Express(TM) Application Dave Funston Algorithm - Fast and Compact Unsigned Binary to BCD Conversion Eugene Miyushkovich, Ryshtun Andrij Simplified FSK (Frequency Shift Keying) Detection Implement a PSoC (8-pin DIP) device suitable for sensi
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number Description Relevance to Course Author Associated Application Notes AN2260,AN2267, AN2294 AN2313 AN2312 AN2310 Pulse Oximeter AN2309 AN2308 nth Order IIR Filtering Graphical Design Tool for PSoC(TM) Comparator with Independently Programmable Hysteresis Thresholds Low-Cost, Two-Cell Li-Ion/Li-Pol Battery Charger with CellBalancing Support Automotive - Remote Keyless Entry Car Alarm with Floating Code AN2
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number AN2279 AN2278 AN2277 Description Relevance to Course Dynamic I2C Addressing Implemented with I2C Hardware User Modules Automotive BLDC Motor Control for PSoC(TM) Capacitive Front Panel Display Demonstration AN2276 AN2274 Binary Weighted Single-Pole IIR Low-Pass Filters Dynamic Reconfiguration Using 'C' AN2273a I2C Bootloader for PSoC(TM), 78-Byte Packet Transfer AN2273 AN2272 I2C Bootloader for PSoC(TM),
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number AN2249 Description Relevance to Course PRS User Module as a One-Shot Pulse Width Discriminator and Debouncer Low CPU Consumption DTMF Detector AN2247 AN2246 PWM Source - High Frequency, High Resolution AN2245 AN2244 AN2239 AN2236 AN2233a AN2231 AN2230 AN2229 AN2228 AN2227 AN2225 PWM Source - High Frequency, High Resolution Smart Smoke Detector ADC Selection Converting Projects from CY8C24x23 to CY8C24x23A
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number Description Relevance to Course Author Associated Application Notes AN2120,AN2148, AN2158 EEE GC 364 – Analog Electronics AN2203 AN2200 Programmable Analog High Current Source.
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number Description Relevance to Course Author EEE GC 491 – Special Projects AN2158 AN2157 Optical PulsOmeter with PSoC Three-Phase Sine Wave Generator AN2156 AN2155 AN2154 A Switched Capacitor Comparator with Programmable Hysteresis EMI Design Considerations for PSoC Voltage Monitoring and Sequencing with PSoC Model Rocketry: Air-Starting Rocket Motors AN2153 AN2152 AN2148 AN2147 Graphics LCD and PSoC Interfac
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number AN2129 Interfacing Assembly and C Source Files AN2128 AN2125T AN2125 3-Wire Interface for a 4-Digit LED Display Blackjack Game (Turkish Version) - Preliminary Standard - Blackjack Game (English Version) - Preliminary AN2124 Morse Decoder for the PSoC AN2122 Standard - DTMF Detector AN2121 AN2120 AN2118 AN2117 Using PSoC Internal Resistors for I2C Communications - Preliminary RTD Temperature Measurement
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number AN2104 Description Relevance to Course Dynamic Re-configuration: Getting Started - Preliminary AN2103 AN2102 AN2101 AN2100 Measuring an Input PWM Protective Controller for a Refrigerator (English Version) Unsigned Division Routines Bootloader: PSoC AN2099a Single-Pole IIR Filters. To Infinity And Beyond! (Japanese Version) AN2099 Single-Pole IIR Filters.
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number AN2087 AN2086 AN2047 AN2046 AN2045j AN2045 AN2044 AN2043 AN2042 AN2041 AN2040 AN2039 Description Relevance to Course Motor Tachometer Speed Calculation Using Hardware Timer Capture Feature Digitally Controlled Sine and Square Wave Generation Ultrasound Motion Sensor Real-Time Operation System for PSoC MCUs Designing a Compact and Flexible LIN Controller (Japanese) Designing a Compact and Flexible LIN Controlle
Cypress PSoC Application Note Description & Relevancy to BITS Course Work Application Note Number AN2026 AN2026 In-System Serial Programming (ISSP) Protocol In-System Serial Programming (ISSP) Protocol (Japanese) AN2025 AN2024 AN2021 AN2020 AN2018 AN2017 AN2016 AN2015 AN2014 CTCSS Carrier Generation with a PSoC Polyphonic Piano What is an Invalid Memory Reference Redundant Fan System Care and Feeding of ICE Pods A Thermistor-Based Thermometer, PSoC Style The Cypress MicroSystems Device YProgrammer Flash
4. Recommendation for Students: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Review CYU Course Material Module 1 Review CYU Course Material Module 2 Review CYU Course Material Module 3 Review CYU Course Material Module 4 Visit http://www.easypsoc.com/book Read PSoC 101 – AN 2010 – Getting started with PSoC, Jeff Dahlin Visit http://www.psocdeveloper.
5. Recommendation for Courseware Development : The following are the recommendations of the author and features available in the current version of the lab manual. 1. Inclusion of Timer, Counter examples as compulsory components in Digital Electronics and Computer Organization Course 2. Inclusion of Assembly Coding Examples in Microprocessor Programming and Interfacing Course 3. Inclusion of C Coding Exercises for specific applications as lab oriented courses specific to PSoC 4.
10. Improvement & Future Work: 1. This hand book covers only the basic design elements and modules in the PSoC Designer Software. Modifications must be done using PSoC Express and many more sections keeping to the overall framework must be added. 2. Description of PSoC Internal Configuration as described in CYU Course Material may be included. 3. More experiments may be designed keeping the format in view – description and screenshot as in software. 4.
7. Sources for Information/References http://www.easypsoc.com/book/ Step By Step Understanding Material 1. CY Technical Reference Manual 2. CY Example Projects 3. CY Courseware 4. Embdedded System Desgin, Oliver Bailey 5. Embedded Systems – Desktop Integration, Oliver Bailey 6. http://www.psocdeveloper.com 7. http://www.time-lines.com/ 8. http://easypsoc.com/book/ 9. http://www.circuitcellar.com/library/print/0804/Eady169/index.htm 10.
8. Appendix : The following sections derived from the handbook are attached for reference of the reader. Please acquire a copy of the manual under development for a complete picture. 1. Timer Module Description 2. Digital Sine Wave Generation 3.
experiments – level 2 SIGNAL GENERATION Generate a fixed frequency Sine Wave Theoretical Analysis (AN 2086) The fourier series of a square wave is given by : ∞ w(t)= a0 + ∑a n =1 i.e a0= n 1 cos nw0 t + bn sin nw0 t 0.8 0.6 1 1 w(t )dt = ∫ T0 T0 T0 + T0 / 4 0.4 ∫ dt =1/2 0.
The building of a square wave: Gibbs' effect 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 0 20 40 60 80 100 120 140 160 MATLAB Code (For Verification) t = 0:.02:3.14; y = zeros(10,length(t)); x = zeros(size(t)); for k=1:2:19 x = x + sin(k*t)/k; y((k+1)/2,:) = x; end plot(y(1:2:9,:)') title('The building of a square wave: Gibbs'' effect') Assuming w(t) = 1 2⎛ 1 1 1 1 ⎞ + ⎜ cos ωo t − cos 3ω 0 t + cos 5ω0 t − cos 7ω 0 t + cos 9ω 0 t − ..
8. 1. 2. The Sine wave output is finally obtained at P0[5] Plug in the USB Connector to the PSoC Mini-Programming Kit. For the first time a new driver installation will take place. We place CY8C29466-24PXI in the dock Programming the PSoC is a 2 step process • Develop the Code in PSoC Designer • Download code to the device 3. Cypress Microsystems | PSoC Designer 4. Choose New Project 5. Type Project Name 6. Incase correct part is not chosen, use View Catalog 7. Generate Main File using C 8.
Notes : 1. Left pane shows preconfigured elements. They can be selected by highlighting the component Æ Right Click Æ Select 2. The resource meter on upper right side shows what part resources are used and available 11.
• • • • Filters Æ BPF2_1 & BPF2_2 Counters Æ Counter16_1 Counters Æ Counter8_1 & Counter8_2 Amplifiers Æ PGA_1 12. Switch from the user module view to the Interconnect view Use standard procedure to place all blocks in the design. The following is a quick revision of the steps 13. Click on the clock input of the 16 bit counter. Select VC1 as shown. This makes it get a clock signal of SysClk=24 Mhz. You can use VC3 to do this if you only need 8 bit divider.
14. We will give the LSB of the 16 bit counter (divide by 8) as clock to the PGA. Scroll down to AnalogClock_0_Select and select DBB00 (where the LSB section of the 16 bit counter is placed). Note : If dividing by less than 256, then we can use an 8-bit counter. By using an 8-bit you will save digital blocks for other things. Now select AnalogColumn_Clock_0 and select AnalogClock_0_Select.
Scroll up again to the first 8 Bit Counter (Counter8_1) This is the counter which actually is being used here to generate the square wave of 4 Khz frequency (32 Khz/4) Select CPU_32_Khz as the clock input. Other options might be tried once the basic experiment is over. Note : The 32 kHz clock is not very accurate, so maybe it is not a good choice. The accuracy of the CPU_32kHz clock is from 15kHz to 64kHz. So, the 4 kHz could be anywhere from 2kHz to 8 kHz.
have used this for convenience of the external connections which I propose to use. Remember to connect Port_0_0 to Port_0_1 because this is what I am assuming from the next step onwards. That is the square wave generated will be available at Port_0_1 now. Note: You can connect the digital output to Port0.0 and route that into the analog input. The analog connection is independent of the digital connection, so both can be connected to the same 13.
One can also connect the AnalogBus to AnalogOutBus_0. This can be then connected to a Pin as shown below. This step is only for verification purposes. 15. Once we get a suitable analog value from the PGA, we need to feed it to the BPF. For the first iteration, one may use the part placement as shown in the figure shown next – other alternatives have their own problems.
16. Click on the input of BPF2_1 FLIN Module and select ACB00 (it might be something different if you placed it differently) Te opposite connection that is from PGA to BPF2_1 is not generally used (or possible!!) Note : The way to set analog connections is by selecting which source is used for each input. Where the output goes cannot be set. This is just the way that PSoC Designer was made to work.
17. Click on the Input of BPF2_2 module and select ASC10 (again this name might be different if your placement has been done differently). But make sure that you connect from the BPF2_1 FLIN module. 18. To obtain the final output (now a sine wave) connect the AnalogBus of the BPF2_2 to the AnalogOutBus_1 19. You will notice that this is fed to buf1. Click on this to connect to Port0_5.
20. Global Resources Settings • 32K_Select and PLL_Mode at Internal and Disable • We are not using an external crystal to drive the processor nor need anything to sync it to. • CPU_Clock=SysClock/8 (=3MHz) • VC1=1 (We don’t need this) • VC2=1 • VC3 Source = SysClk/1 (Default) • VC3 Divider=1 • Every other parameter default • Notes : The "best" speed to set the CPU for experimental use is 12MHz. That is the maximum speed over the full voltage range (using 24MHz requires >4.75V).
21. Refer to the Band Pass Filter Design Utility. The following parameters can be used. Note : The Wizard does not currently work properly. Cypress plans on having it fixed in a future release. 22. The following parameters for the Programmable Gain Amplifier should be used. • For secondary testing, the gain can be varied here and experimented Notes : • This is prior to the filter, so only setting gains <1 should have an effect. Another option would be to change the gain in the Filter.
23. The User Module Parameters shown alongside for the 8 bit counter should be used. One can experiment with different values once the primary result has been obtained. Counter8_2 is to show how broadcast buses (BC0) here can be used to take the output of one module can be fed to another. This was actually used in AN 2086 to provide control of the frequency of the sine wave generated using a digital encoder. For more information, refer the appendix. 21. Shift to Application Editor 22.
• With more components added, more files will be created. 21 Type the following code in main.asm ; Assembly main line include "m8c.inc" ; part specific constants and macros include "memory.inc" ; Constants & macros for SMM/LMM and Compiler include "PSoCAPI.
25. Select Program 26. Make sure you check “power device” icon after “Programming Successed” is displayed 27. Make sure Port0[5] is connected to a CRO!! Modifications/Exericse : 1. Connect the output of BPF2_1 FLIN module to the analog bus, then via the buffer to a pin of your choice. Observe the difference if any between the outputs of the two Band Pass Filters. This will enable us to understand why at all two BPF Filters should be used. 2.