PSoC™ 4 Forum Discussions
Greetings,
I am currently looking at the CY8CKIT-042-BLE development kit. I would like to know if MATLAB code can be ported into the CY8CKIT-042-BLE development environment for coding implementation. If so what is the process for doing so.
Thanks in advance for your assistance.
I would also appreciate some haste in this matter.
Show LessHi Everyone,
For my case, I am using the CE214022 to create a low power Capsense design, and add a widget to detect a liquid stream for disable the touch, but seems this guard detection were failed, do you have any idea that where I can put the guard detection process into my code? The main code is as following, thanks!
Show Lessint main()
{
/* Variable to hold current button status */
uint32 buttonStatus = OFF;
/* Variable to hold the current device state
* State machine starts with sensor scan state after power-up
*/
DEVICE_STATE currentState = SENSOR_SCAN;
/* This variable is used to indicate the current power mode */
SCAN_MODE deviceScanMode = FAST_SCAN_MODE;
/* This variable is used to implement a software counter. If the value
* of this counter is greater than SCANMODE_TIMEOUT_VALUE, it indicates that the button sensor
* was inactive for more than 3s.
*/
uint16 softCounter = RESET;
/* Enable global interrupts. */
CyGlobalIntEnable;
#if TUNER
/* Initialize I2C component for CapSense tuner */
EZI2C_Start();
/* Set up communication data buffer to CapSense data structure to
* expose to I2C master at primary slave address request
*/
EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam), sizeof(CapSense_dsRam),\
(uint8 *)&CapSense_dsRam);
CapSense_Start(); /* Initialize Component */
CapSense_ScanAllWidgets(); /* Scan all widgets */
for(;;)
{
/* Do this only when a scan is done */
if(CapSense_NOT_BUSY == CapSense_IsBusy())
{
CapSense_ProcessAllWidgets(); /* Process all widgets */
CapSense_RunTuner(); /* To sync with Tuner application */
if (CapSense_IsAnyWidgetActive()) /* Scan result verification */
{
/* add custom tasks to execute when touch detected */
}
CapSense_ScanAllWidgets(); /* Start next scan */
}
}
#else
RX_ISR_StartEx(uart_int);
/* Initialize the CapSense CSD block */
CapSense_Start();
/* Configure CapSense parameters for button widget to scan them individually */
CapSense_SetupWidget(CapSense_BUTTON_WDGT_ID);
//CapSense_SetupWidget(CapSense_GUARDSENSOR_WDGT_ID);
/* Watchdog is used to control the loop time in this project and watchdog
* is set to generate interrupt at every LOOP_TIME_FASTSCANMODE in fast scan mode
* and at LOOP_TIME_SLOWSCANMODE in slow scan mode
*/
WDT_Start();
/* Put the num 5 cap raw data to srand*/
srand(CapSense_BUTTON_SNS5_RAW0_VALUE);
//show_preamble();
UART_Start();
all_led_on();
initialiseFlag = TRUE;
needPreamble = PREAMBLE_ON;
set_mode(ACTIVE_MODE);
for(;;)
{
/* Switch between sensor-scan -> wait-for-scan -> process -> sleep states */
switch(currentState)
{
case SENSOR_SCAN:
/* Initiate new scan only if the CapSense hardware is idle */
if(CapSense_NOT_BUSY == CapSense_IsBusy())
{
/* In fast scan mode, left button and right button is scanned individually */
if(deviceScanMode == FAST_SCAN_MODE)
{
/* Scan the sensors which are in the button widget i.e left button and right button */
CapSense_ScanAllWidgets();
}
/* In slow scan mode, only ganged sensor is scanned. Since we have only one ganged sensor,
* the sensor is always connected to AMUXBUS in this mode.
* This avoids time taken to connect the sensor to AMUXBUS every time the ganged sensor is scanned.
*/
else
{
CapSense_CSDScanExt();
}
/* Put CPU to sleep while sensor scanning is in progress */
currentState = WAIT_FOR_SCAN_COMPLETE;
}
break;
case WAIT_FOR_SCAN_COMPLETE:
/* Device is in CPU Sleep until CapSense scanning is complete or
* device is woken-up by either CapSense interrupt or I2C interrupt
*/
/* Disable interrupts, so that ISR is not serviced while
* checking for CapSense scan status.
*/
interruptState = CyEnterCriticalSection();
/* Check if CapSense scanning is complete */
if(CapSense_NOT_BUSY != CapSense_IsBusy())
{
/* If CapSense scannning is in progress, put CPU to sleep */
CySysPmSleep();
}
/* If CapSense scanning is complete, process the CapSense data */
else
{
currentState = PROCESS_DATA;
}
/* Enable interrupts for servicing ISR */
CyExitCriticalSection(interruptState);
break;
case PROCESS_DATA:
/* Set next state to SLEEP */
currentState = SLEEP;
/* Clear the variable that is used for both the button status */
buttonStatus = CLEAR;
if(deviceScanMode == FAST_SCAN_MODE)
{
/* Update baseline and sensor status for both the button sensors */
CapSense_ProcessWidgetExt(CapSense_BUTTON_WDGT_ID, CapSense_PROCESS_CUSTOM);
/* If button widget is reported active, process the
* button active status
*/
if(CapSense_IsWidgetActive(CapSense_BUTTON_WDGT_ID) && ((0x01 << CapSense_GUARDSENSOR_WDGT_ID) != CapSense_WDGT_STATUS0_VALUE))
{
//if(!CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS12_ID))
//{
//preamble();
/* Set left button state */
if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS0_ID))
{
buttonStatus |= NUM0_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS1_ID))
{
buttonStatus |= NUM1_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS2_ID))
{
buttonStatus |= NUM2_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS3_ID))
{
buttonStatus |= NUM3_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS4_ID))
{
buttonStatus |= NUM4_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS5_ID))
{
buttonStatus |= NUM5_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS6_ID))
{
buttonStatus |= NUM6_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS7_ID))
{
buttonStatus |= NUM7_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS8_ID))
{
buttonStatus |= NUM8_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS9_ID))
{
buttonStatus |= NUM9_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS10_ID))
{
buttonStatus |= ENTER_BUTTON_MASK;
}
/* Set right button state */
else if(CapSense_IsSensorActive(CapSense_BUTTON_WDGT_ID, CapSense_BUTTON_SNS11_ID))
{
buttonStatus |= LOCK_BUTTON_MASK;
}
/* Control RGB LED based on button status */
LED_Control(buttonStatus);
/* Reset the software counter if any button is active. */
softCounter = RESET;
}
/* If none of the buttons are active, execute below code */
else
{
/* Increment the software counter every LOOP_TIME_FASTSCANMODE if button
* touch is not detected.
*/
softCounter++;
LED_Control(buttonStatus);
/* Update previous button status which is saved in LED_Control API */
//LED_Control(buttonStatus);
/*
if((softCounter >= LED_OFF_DELAY_VALUE) && (prevButtonStatus != OFF))
{
switch(prevButtonStatus)
{
case NUM0_BUTTON_MASK:
Num0_Write(0);
break;
default:
all_led_on();
break;
}
prevButtonStatus = OFF;
}
*/
/* If finger is not on sensor for SCANMODE_TIMEOUT_VALUE, switch off the
* LEDs and switch mode to slow scan mode to reduce power consumption
*/
if(softCounter >= SCANMODE_TIMEOUT_VALUE)
{
/* Watchdog is configured to generate interrupt at LOOP_TIME_SLOWSCANMODE */
watchdogMatchValue = WDT_TIMEOUT_SLOW_SCAN;
initialiseFlag = FALSE;
/* Set mode to slow scan mode to scan sensors at LOOP_TIME_SLOWSCANMODE */
deviceScanMode = SLOW_SCAN_MODE;
/* Configure ganged sensor and connect it to AMUXBUS */
CapSense_CSDSetupWidgetExt(CapSense_GANGEDBUTTON_WDGT_ID, CapSense_GANGEDBUTTON_SNS0_ID);
}
}
}
/* If deviceScanMode is SLOW_SCAN_MODE, perform the following tasks */
else if(deviceScanMode == SLOW_SCAN_MODE)
{
/* Update baselines of ganged button widget */
CapSense_ProcessWidget(CapSense_GANGEDBUTTON_WDGT_ID);
/* If ganged widget is active in slow scan mode move to
* fast scan mode where sensors are scanned individually at LOOP_TIME_FASTSCANMODE
*/
if(CapSense_IsWidgetActive(CapSense_GANGEDBUTTON_WDGT_ID))
{
deviceScanMode = CHECK_GUARD;
currentState = SENSOR_SCAN;
CapSense_CSDSetupWidgetExt(CapSense_GUARDSENSOR_WDGT_ID, CapSense_GUARDSENSOR_SNS0_ID);
}
}
else
{
CapSense_ProcessWidget(CapSense_GUARDSENSOR_WDGT_ID);
if(!CapSense_IsWidgetActive(CapSense_GUARDSENSOR_WDGT_ID))
{
//CapSense_CSDSetupWidgetExt(CapSense_GUARDSENSOR_WDGT_ID, CapSense_GUARDSENSOR_SNS0_ID);
//CapSense_CSDScanExt();
//CapSense_SetupWidget(CapSense_GUARDSENSOR_WDGT_ID);
//CapSense_ProcessWidget(CapSense_GUARDSENSOR_WDGT_ID);
//if(CapSense_IsWidgetActive(CapSense_GUARDSENSOR_WDGT_ID))
//{
currentState = SENSOR_SCAN;
/* Set watchdog match value to fast scan mode */
watchdogMatchValue = WDT_TIMEOUT_FAST_SCAN;
/* Change the device mode to fast scan mode to provide fast touch response */
deviceScanMode = FAST_SCAN_MODE;
/* Configure button widgets parameters for scanning in fast scan mode */
CapSense_SetupWidget(CapSense_BUTTON_WDGT_ID);
//CapSense_SetupWidget(CapSense_GUARDSENSOR_WDGT_ID);
}
else
{
currentState = SENSOR_SCAN;
deviceScanMode = SLOW_SCAN_MODE;
CapSense_CSDSetupWidgetExt(CapSense_GANGEDBUTTON_WDGT_ID, CapSense_GANGEDBUTTON_SNS0_ID);
}
}
if(UARTRX_Buf)
{
switch(UARTRX_Buf)
{
case 0x61:
case 0x62:
needPreamble = UARTRX_Buf;
break;
case 0x63:
set_mode(SETTING_MODE);
break;
case 0x66:
softCounter = SCANMODE_TIMEOUT_VALUE;
break;
case 0x68:
break;
case 0x6B:
break;
case 0x6C:
break;
default:
break;
}
UARTRX_Buf = 0;
}
break;
case SLEEP:
/* In fast scan mode, put the device to only CPU sleep as TCPMW block is ON
* to drive RGB LEDs and it cannot work in deep-sleep mode
*/
if(deviceScanMode == FAST_SCAN_MODE)
{
CySysPmSleep();
}
/* In slow scan mode, device can be put to deep-sleep as TCPWM is off */
else
{
//Send_UART(0x6A);
if(doorlockState != SLEEP_MODE)
{
Send_UART(0x6A);
set_mode(SLEEP_MODE);
}
EnterDeepSleepLowPowerMode();
}
/* Start scanning the sensors only if interrupt occured due to WDT.
Interrupt can also occur due to I2C interrupt while tuner is running.
In such cases, sensor is not scanned until WDT interrupt has occured
*/
if(wdtInterruptOccured)
{
/* Set state to scan sensor after device wakes up from sleep */
currentState = SENSOR_SCAN;
wdtInterruptOccured = FALSE;
/* Calibrate the ILO to ensure accurate scan intervals */
CalibrateWdtMatchValue();
}
break;
default:
/*******************************************************************
* Unknown power mode state. Unexpected situation.
******************************************************************/
CYASSERT(0);
break;
}
}
#endif
}
Hello everybody,
I am trying to blink a led using a timer. My configuration is very simple:
On timer component
clock: 32Khz
period: 32000
trigger mode: node
capture:
enable mode: software
run mode: continuous.
The problem is that after uploading the led lights but is not blinking.
Here is the c code:
The commented lines is what i tried. Thank you in advance.
/* ========================================
*
* Copyright YOUR COMPANY, THE YEAR
* All Rights Reserved
* UNPUBLISHED, LICENSED SOFTWARE.
*
* CONFIDENTIAL AND PROPRIETARY INFORMATION
* WHICH IS THE PROPERTY OF your company.
*
* ========================================
*/
#include "project.h"
int array[4]={1,2,4,8};
volatile _Bool state=0;
CY_ISR(TMR_ISR_HANDLER){
if(state==1){
state=0;
LED_1_Write(1);
}
else{
state=1;
LED_1_Write(0);
}
//TMR_WritePeriod(32000);
//TMR_Stop();
//TMR_WritePeriod(5000);
//TMR_Start();
};
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
TMR_ISR_StartEx(TMR_ISR_HANDLER);
TMR_Start();
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
for(;;)
{
/* Place your application code here. */
}
}
/* [] END OF FILE */
Show LessHi,
I am using MicroController CY8C4246LTIDM405. I am trying to receive command from Server using USSD and Sim868 GSM module is being used. My problem is if I am sending two data from Server with a time difference of even 1 second, I am able to receive only one data at a time not the other one but I need to receive both of them. So, I am actually polling for UART data and the logic is something like this:
while((c = UART_SIM868_UartGetChar()))
ATCC_receiveChar(&SIM868, c);
The ATCC_receiveChar function looks something like this:
void ATCC_receiveChar(ATCC_t *atcc, char c)
{
if (atcc->AT_inputPos < ATCC_BUFFER_INPUT)
atcc->AT_input[atcc->AT_inputPos++] = c;
if (c == '\n' && atcc->AT_inputPos <= 3)
atcc->AT_inputPos = 0;
else if (c == '\n')
ATCC_inputParse(atcc);
}
So in the above function, the data will break as soon as' \n'. To receive the second command, I first of all tried to see if it is even able to receive the second command and so to rule it out, I actually put a logic that if two '\n's are received then break . I added this logic in place of
else if (c == '\n')
ATCC_inputParse(atcc); and it was able to receive but because of this logic, I am facing problem in sending data to the server. I don't know how to solve this problem and any leads will be appreciated.
Thanks.
Show LessWe are manufacturing our own Cypress ble dongle according to the link
http://www.cypress.com/documentation/development-kitsboards/cy5670-cysmart-usb-dongle,
I want to know whether we need any external programmer to burn the hex file to the dongle or it can be done through USB port from PSOC programmer?
We also have CY8CKIT-042-BLE kit with us, can we use that kit to program the CY5670 ble usb dongle?
Show LessHello,
My design is based on two simple buttons.
When I disconnect the sensor,CapSense_CSD_sensorRaw[0] or CapSense_CSD_sensorRaw[1] will turn into 0 with little probability.
Many thanks in advance,
Joe
Show LessHi,
I am using an RTC component in my progect,and I want to know if there is any way to compensate for the crystal frequency error from its nominal frequency of 32.768 kHz.
thanks first.
Show LessI would like to know
the Vref value for "CSX" Sensing Method, and they are using PSOC “4000S” series.
We are referring the
AN85951 3.1.1.2 CSX Sensing Method, and the VREF voltage is 1.2V. Is it ok to
think that the VREF voltage is fixed at 1.2V for PSOC 4000S?
Best Regards
Arai
Show LessI have PSoc 4 BLE- A, I would like to create a Project to determine ambient temperature based on Thermistor. Also would like to display that value on 16Bil GLCD display. I found few project but not related with PSoc4 BLE-A. Does anyone has idea how to create that project? Your response will be highly appreciated.
Show Less