Tuesday, October 13, 2009

Home

How to create a simple 3 button USB mouse using PSoC USB device CY8C24794

Writing code for a usb mouse is such a complicated thing that anybody learning the report structure will go mad. Here comes Cypress's PSoC .PSoC device CY8C24794 is a USB programmable device with a USB interface.Also it can be powered using the USB cable.We can make a simple 3 button mouse using this device within 10 mins,if the CY3214 kit is available.The PSoC makes it all possible.!!!!!The most important thing is to understand the working of basic things and then the technical stuff will become simple.Here a person who doesn't know how to configure the PSoC using the PSoC designer software is advised to go through the Cypress site to get the detailed tutorial. Anybody can download the tutorial by registering into the Cypress site.Also there is a site called PSoC developer where we can find some PSoC related useful posts.This is the code for the 3 button USB mouse
//----------------------------------------------------------------------------
// C main line

//----------------------------------------------------------------------------

#include // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include "DualADC8.h"

BYTE abMouseData[4] = {0,0,0,0};


void main()
{

/*adc initialisation*/
char cResult1, cResult2;
char cResult1_prev, cResult2_prev;
M8C_EnableGInt; // Enable global interrupts
DUALADC8_Start(DUALADC8_HIGHPOWER); // Turn on Analog section
DUALADC8_SetCalcTime(100); // Set CalcTime to 100
DUALADC8_GetSamples(); // Start ADC
cResult1=0;cResult2=0;
cResult1_prev=0;cResult2_prev=0;
/*usb initialisation*/

M8C_EnableGInt; //Enable Global Interrupts
USBFS_Start(0, USB_5V_OPERATION); //Start USBFS Operation using device 0
//and with 5V operation
while(!USBFS_bGetConfiguration()); //Wait for Device to enumerate
//Enumeration is completed load endpoint 1. Do not toggle the first time
USBFS_LoadInEP(1, abMouseData, 3, USB_NO_TOGGLE);

/*lcd initialisation*/
LCD_1_Start();
LCD_1_Position(0,5);
while(1)
{
while(!USBFS_bGetEPAckState(1)); //Wait for ACK before loading data
//ACK has occurred, load the endpoint and toggle the data bit
USBFS_LoadInEP(1, abMouseData, 3, USB_TOGGLE);
while(DUALADC8_fIsDataAvailable == 0);
cResult1_prev=cResult1;
cResult2_prev=cResult2;
cResult1 = DUALADC8_cGetData1();
cResult2 = DUALADC8_cGetData2ClearFlag();
{
if ((cResult1_prev-cResult1)> 20 ||(cResult1-cResult1_prev) > 20)
abMouseData[1] = 0x01;
else if ((cResult1_prev-cResult1)<> 20 ||(cResult2-cResult2_prev) > 20)
abMouseData[2] = 0x01;
else if ((cResult2_prev-cResult2)< style="text-align: justify;">Here in this code the mouse x and y motions are mimicked by using 2 potentiometers.The PSoC core reads the ADC (8bit)continuously and sends the conditioned value to the PSoC core for processing and sending the required data to the system. The required value is sent through the USB interface.The PRT0DR is the port 0 data register.where the data read from the input ports of the PSoC is stored. The abMouseData is an array which is actually called the report descriptor by software guys who code for this complex USB HID device.The format for the USB HID mouse is given below


-->

Monday, August 31, 2009

Home

PSoC a new way to design

Cypress's PSoCĀ® Programmable System-on-Chip is the most complete solution for embedded systems, combining an 8-bit microcontroller, flash memory, and SRAM with customizable analog and digital blocks.

PSoC is a software configured, mixed-signal array with a built-in Microcontroller unit core. The core is a Cypress proprietary, 8bit harward design called the M8C. PSoC has three separate memory spaces: paged SRAM for data, flash memory for instructions and fixed data, and I/O Registers for controlling and accessing the configurable logic blocks and functions.
Here is a comparison table showing the major differences between PSoC ASIC and FPGA



PSoC ASIC
FPGA
Time to Market hours
years
hours
Design Complexity Very less
More
less compared to ASIC
Configuration can be changed during run time cannot be changed can be changed to some extend
Freq of operation Very less More Less comp to ASIC


The configuration is obtained by loading instructions from the built-in Flash memory in a PSoC whereas in an FPGA the configuration is loaded at the begining from an EEPROM into SRAM distributed memory as well as block memory.Also the FPGA uses some configurable logic blocks(CLBs).

PSoC most closely resembles a MCU in usage, where code is executed to interact with the user-specified peripheral functions (called "User Modules"), using automatically generated APIs and interrupt routines. The PSoC Designer IDE generates the startup configuration code and peripheral APIs automatically based upon the users selections in a visual-studio-like GUI.Cypress offers a visual, code-free embedded design tool for PSoC called PSoC Express. Using PSoC Express, most features of the PSoC can be accessed with drag and drop icons and logical expressions. The vishual design is compiled to executable code without exposing the user to the underlying converted code, though a visual design can be converted and used as a basis of a traditional code-based design in PSoC Designer. Visual design elements cover features such as temperature sensors, fan control, accelerometers, I2C master and slave protocols, USB virtual serial ports, capacitive sensors, and wireless 2.4 GHz radio communications.PSoC programmer is another software that is available in cypress.com that can be used to program the bitstream into the PSoC devices.
PSoC Designer
PSoC programmer
You have to register for getting the softwares and u can create cases for queries in cypress.com.

In a PSoC device the user defines What functions appears,When they appear and how !!!!!

Four Levels of Documentation
1)Technical ref manuals
2)User module datasheets (available with PSoC designer software)
3)Device datasheets
4)Project Config datasheets generated by the tool at the end of the design

Dynamic Reconfiguration
Dynamic reconfiguration is a similar kind of a thing like polymorphism in C++. One device performing different functions at different times. Multiple function sets operate on same hardware at different times in the same application. In this case we dynamically load the configuration at run time.
PSoC Applications
Voltage Monitoring,Airflow Sensing, Humidity Sensing, I2C, SPI, UART, CPU Reset, Temp Sensing, Pressure Sensing, Current Sensing, Accelerometers, Fan Control, USB devices etc are the typical applications where the PSoC can be used.


-->

StatCount - Traffic counter

Add to Technorati Favorites