Download Example Project

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Radio transmitter design wikipedia , lookup

HD-MAC wikipedia , lookup

Amplifier wikipedia , lookup

Integrating ADC wikipedia , lookup

Switched-mode power supply wikipedia , lookup

Transistor–transistor logic wikipedia , lookup

Operational amplifier wikipedia , lookup

Schmitt trigger wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Analog-to-digital converter wikipedia , lookup

Phase-locked loop wikipedia , lookup

Oscilloscope history wikipedia , lookup

Valve RF amplifier wikipedia , lookup

Flip-flop (electronics) wikipedia , lookup

Time-to-digital converter wikipedia , lookup

Opto-isolator wikipedia , lookup

Rectiverter wikipedia , lookup

Transcript
User Module Project - OneShot
Project Name: Example_OneShot_CY8C29466
Programming Language: C
Associated Part Families:CY8C29/27/24/21/20xxx,CY8CLED02/04/08/16
CYWUSB69xx,CY8CLED03D/04D
Software Version: PSoC Designer™ 5.2
Related Hardware: CY3210 PSoCEval1 Board
Project Objective
This project demonstrates the operation of OneShot8 User Module that produces a single pulse in response to an input
signal.
Overview
Sometimes a device must produce a single pulse in response to an input signal. Such devices are called one-shots (or
‘univibrators’ or ‘monostable multivibrators’) and are used to delay and reshape input pulses.
One-shots are also used as debouncers. The source of the bounce does not always originate from mechanical switches.
The input signal has curved rising and falling edges. A comparator responds to an incoming pulse by triggering a signal as
shown in Figure 1.
Figure 1. Ideal Operation of a Comparator
1
Input pulses (and thresholds) have a noise component. The comparator also has its own noise. As a result, it responds with
multiple triggers when the signal crosses the threshold (see Figure 2).This phenomenon is called bouncing.
Figure 2. Reality Operation
False trigger is counted as the noise in the signal introduces extra threshold crossings. One way to eliminate false triggers is to
add a hysteresis to the comparator.
An alternative is to use ‘One Shots’. When the first pulse is sent out for a specified period of time, the device ignores any other
input pulses even if one is reactivated by a bounce. As a result, very clean output pulses are received.
The OneShot8 User Module produces a single pulse in response to an input signal. It can be used to reshape short input
pulses and generate single pulses with a required duration.
The OneShot8 User Module compares the output of a CRCPRS hardware block to a row interconnect. The relax time is
®
selectable and can be 8,16,24 or 32 clock pulses, using one, two, three or four PSoC digital blocks, respectively.
The OneShot8 User Module consumes one digital PSoC block per 8 clock pulses of output signal length.
User Module List and Placement
The following table lists user modules used in this project and the hardware resources occupied by each user modul e.
User Module
Placement
OneShot
DBB00
User Module Parameter Settings
The following tables show the user module parameter settings for the user modules used in the project.
OneShot8
Parameter
Value
Comments
Clock
VC3
It defines the Relax time after which the Output appears. VC3 is configured
to generate a clock of 2.823 Khz
Input
Row_0_Input_0
OneShot8 User Module Input
Output
Row_0_Output_0
OneShot8 User Module Output
Clock Sync
Sync to SysClk
Synchronize the clock to Sys.Clk (Source clock)
Invert Input
Normal
Input is active high
2
Global Resources
Important Global Resources
Parameter
Value
Comments
Power Setting
5V/24 MHz
Selects 5V operation and 24 MHz SysClk.
CPU Clock
SysClk/1
Sets CPU Clock to 24 MHz
VC1 = SysClk/N
10
Divide 24 Mhz Clock by 10.
VC2 = VC1/N
10
Divide VC1 Clock by 10.
VC3 Source
VC2
VC2 is the source for VC3 divider.
VC3 Divider
85
Divide VC2 Clock Output by 85.
Pin Configuration
Port Pin
Direction
Select
Drive Mode
P0[0]
Input
GlobalInEven_0
High Z
P0[4]
Output
GlobalOutEven_4
Strong
P0[6]
Output
GlobalOutEven_6
Strong
P1[0]
Output
StdCPU
Strong
3
Hardware Connections
The following is the schematic diagram for the project. The OneShot8 User Module input is routed from P0.0
through Row_0_Input_0 and the OneShot8 User Module output is routed through Row_0_Output_0 to P0.4.
Figure 3. Project Schematic Diagram
The project can be tested using the CY3210 – PSoC Eval1 board. The following connections are made on the CY3210 board:




Input connected to P0.0 (Give square wave input of frequency 100 Hz from a signal generator).
Output connected to P0.4.
VC3 Clock is routed to P0.6 through GlobalOutEven_6 net.
P1[0] is connected to LED1 in J5 header.
4
Operation
On reset, all hardware settings from the device configuration are loaded into the device and main.c is executed.
The following operations are performed in main.c.




The OneShot user module is started.
Global interrupts are enabled using M8C_EnableGInt macro.
The interrupt Operation mode of the Oneshot User Module is enabled. The output generates an interrupt on every rising
edge. The ISR for Oneshot User Module is written in C and is declared as ISR using the ‘#pragama interrupt_handler’
directive. A ljmp instruction to the C OneShotISR is placed inside the OneShot8INT.asm file within the user code
markers.
Continue looping infinitely. If an interrupt comes from the Oneshot module, execute the following ISR:

OneShotISR: Toggle an LED that is connected to P1[0].
The waveforms observed in the OneShot UM are shown in the following diagram.
Figure 4. OneShot UM Waveform
5
The timing diagram of the Oneshot User Module follows.
Figure 5. OneShot UM Timing Diagram
Testing the Project



After downloading the project Example_Oneshot into PSoC, power on the CY3210 PSoCEval1 board.
Apply the input signal in P0 [0] and observe the output of Oneshot User Module in P0 [4].
The waveforms of clock, input, and output signals can be observed in the oscilloscope.
Upgrade Information
As the ljmp instruction to the C ISR for the OneShot8 Module is placed inside the user code markers inside the
OneShot8INT.asm file, this change is preserved when the project is generated and built. If the source file for the
OneShot8INT.asm file changes in a future release of PSoC Designer™, this instruction may get overwritten. So, if you have
upgraded the PSoC Designer and find that the project is not working, check the following.
Open OneShot8INT.asm file and check if there is an ‘ljmp _OneShotISR’ instruction present in the user code area in the
_OneShot8_ISR function. If not, add this line of code within the user code markers.
6