Escolar Documentos
Profissional Documentos
Cultura Documentos
AN2333
Authors: Somsak Sukittanon, Ph.D., Stephen G. Dame, MSEE
Associated Project: Yes
Associated Part Family: CY8C21xxx, CY8C24xxxA, CY8C24794, CY8C27xxx, CY8C29xxx
GET FREE SAMPLES HERE
Software Version: PSoC® Designer™ 4.2
Associated Application Notes: AN2329, AN2332
[+] Feedback
AN2333
The core of a state machine function needs to be state table. Referring to the code from Figure 3, if the next
changed. First, the state machine checks the state is listed as STATE_INTERRUPT, the program
STATE_INTERRUPT table. If there is no event occurring, ignores updating the next state. Therefore, the next state
then it checks the current state. in STATE_INTERRUPT can be listed to anything based
on the application. An event such as ADCDATE_READY
If there is one event in STATE_INTERRUPT, the state may not require changing the next state, but an event
machine executes the action and exit functions and leaves such as TIMER_END may require changing to a new
the state machine routine without checking any current state.
Figure 1. State Machine Design for ADC Conversion and LCD Display Project (PSoCEval1 Example Project #1)
Using a New Approach
EVENT_ADCDATA_READY
ACTION_NOP STATE_INTERRUPT
SF_NOP
EVENT _UART_RECEIVE
ACTION_TOGGLELCDTEXT
SF_PRINTLCD_AND_SENDUART
STATE_IDLE
[+] Feedback
AN2333
PSoC:
Interfacing PSoC to Windows Applications 1. Same functionality as discussed in Application Note
In Application Note part II, we discussed the ADC and part II.
LCD display example using the CY3210-PSoCEval1
board. After we run the project and hook the serial port to 2. Additionally, the UART User Module is able to receive
the PC, the data can be displayed using a simple program and extract messages sent from the PC.
like Tera Term Pro. In this note, we give an example of Windows Application:
how to create a more sophisticated program with PSoC
and a Windows Application. The communication, both 1. Retrieve data sent from PSoC and show that number
transmit and receive mode, between PSoC and the PC is on the display. In the mean time, plot the graph of the
done via serial communication. Microsoft Visual Basic is current number in real-time.
used for building the application. The reader can easily
2. Send data from PC back to PSoC. New message text
extend our example to different applications.
will show on LCD line 1.
Following are the primary responsibilities.
[+] Feedback
AN2333
Modifying the PSoC Project No changes are required for transmitting UART data. For
receiving data, the EVENT_UART_RECEIVE function
There are parameters that need to be set for the PSoC
periodically checks if the buffer has received anything. If
UART User Module. First, the RxCmdBuffer is enabled.
the PSoC receives message data,
The size of the UART buffer is chosen based on the
ACTION_TOGGLELCDTEXT extracts the ASCII
application, and in our case, it is chosen to be 16.
characters and puts them into LCD buffers. Afterward, the
CommandTerminator is set to ASCII char #13, which is
receive command buffer is reset for the next command.
CR. Space, char #32, is used to separate each command
After compiling the project and downloading it into the
and the UART does not accept NUL, char #0.
evaluation board, we can see that it runs exactly the same
as the project from the previous note (part II AN2332)
because the PSoC has not yet received any data from the
PC.
case ACTION_TOGGLELCDTEXT:
if(inputstrPtr = UART_1_szGetParam())
{
for (index=0;index<14;index++)
LCDStateText[index] = ' ';
bLength = strlen(inputstrPtr); //length of the data
if (bLength > 14)
bLength = 14;
for (index=0;index<bLength;index++)
LCDStateText[index] = inputstrPtr[index];
}
UART_1_CmdReset();
break;
[+] Feedback
AN2333
Figure 6. (a) Microsoft Visual Basic Project and (b) UART Setup
(a) (b)
Figure 7. (a) A Running Windows Application Connecting to PSoC; (b) PSoC Before Getting New Message;
(b)
(a) (c)
[+] Feedback
AN2333
[+] Feedback
AN2333
In March of 2007, Cypress recataloged all of its Application Notes using a new documentation number and revision code. This new
documentation number and revision code (001-xxxxx, beginning with rev. **), located in the footer of the document, will be used in all
subsequent revisions.
PSoC is a registered trademark of Cypress Semiconductor Corp. "Programmable System-on-Chip," PSoC Designer, and PSoC Express are
trademarks of Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their
respective owners.
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone: 408-943-2600
Fax: 408-943-4730
http://www.cypress.com/
© Cypress Semiconductor Corporation, 2006-2007. The information contained herein is subject to change without notice. Cypress Semiconductor
Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any
license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or
safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as
critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The
inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies
Cypress against all charges.
This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide
patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a
personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative
works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress
integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source
Code except as specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the
right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or
use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a
malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems
application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
[+] Feedback