PSoC™ 4 Forum Discussions
Hello,
I’m trying to use the function CySysPmHibernate() in PSoC 4500s. I get an error:
Is something wrong with the way how this function is called or is there another function to be called?
Thanks.
Show LessHello,
I have yellow text color ports when the CSD sensors are placed(P1[0 - 4], P1[7], P2[0 - 7]).
Please see below. The device is CY8C4124LQI-S413.
The PSoC Creator user guide has the following instructions:
This just tells me that there are other analog resources, and I don't think I should be careful as a CSD, is that correct?
Best regards,
Yocchi
Show LessI have a Liquid tolerance problem with CapSense. When two CapSense buttons are covered by a water stain.
If I touch either button, both buttons will be activated . How do I get these two buttons to activate correctly(the two buttons do not activate at the same time). Achieve the purpose of Liquid tolerance?
Show Less
在宣讲资料中有看到PSoC Capsense组件可以满足“enable touch through > 5mm thick overlay”
参考AN64846 手册,基于PSoC4100S+的capsense实现glove touch,厚度5mm;
AN64846手册中没有介绍glove touch设计的注意事项,请问着这种设计要着重关注哪些方面呢?
Show LessHi,
I wish start to examine the booloader with BLE using the example code "BLE_OTA_UpgradableStackExample_Stack01".
The PSOC is 4.4 version. The problem is that the build doesn't create the file .hex but I receive the error message:
"Error in component: Bootloadable. The referenced Bootloader is invalid. Verify the Bootloader dependency is correct in the Bootloadable Component, then build project. Invalid bootloader elf file. Unable to read the elf file (C:\PSoC Creator\BLE_OTA_UpgradableStackExample_Stack01\BLE_OTA_UpgradableStackExample_Stack01.cydsn). The path does not exist".
No build-> no .hex file. May be that there are wrong settings...
Any help?
Thanks in advance!
Show Less嗨~ 您好!
請問在PSoC Creator選擇pin腳時, 有些pin腳顯示綠色, 有些pin腳顯示黃色, 如附圖,
當可以選綠色的時候我覺得很有信心,
但是當只有黃色可以選擇時, 我便有點不放心選擇它們, 因為我不是很明白這些黃色腳位的意義,
可以麻煩您說明一下這些黃色的pin腳選擇嗎?!
謝謝!
Show LessHi,
In the past, I have used the method outlined in Application Note AN84858 to program CY8C4127 chips on custom boards, using the PSoc 5LP on CY8CKIT-042-BLE as a host processor.
However, I have now had to move to the larger memory version (the CY8C4128LQI-BL483) and I am having issues getting the HSSP process to work.
Looking at section 14.2.1 of document 001-84858_AN84858, it seems to suggest that its not possible to do an HSSP program as the 256KB for the PSOC4 chip is too much for the PSoC 5LP chip's memory, and it indicates some changes that are needed.
But its not clear if I have to make those changes myself to the B_HSSP_Pioneer files (Heximage.h, Heximage.c and Datafetch.c), or if there is an alternative version of the B_HSSP_Pioneer project that should be used for the 256kB chips.
Has anyone gone down this path and if so, can they explain what I need to do to get things to work?
Thanks and regards,
Mike
Show LessHi
I am developing an application using a low power BLE device based on the CyBLE 214009-000 module, and a windows program using c# and the CySmart API Started from the published example).
Most of the app is written and works, including reading and setting ports, getting A/D info both reading and by notification and I am now (belatedly!) exploring the low power behavior of the device. Both firmware and software are getting a bit sizeable, so I am not going to post the entire thing, but if someone wants more details about some aspect please let me know and I will try and reduce to a managable size and still demonstrate that aspect.
I have two problems, one around the behaviour of CySmart, and one on the behavior of C#.
1) The CySmart application removes the "connected" tic when the peripheral is timed out.
I would like to do the same in order to manage the graceful degredation of the link, and show the user (me!) what is going on. However I cannot find any way of achieving this directly using the CySmart API to interrogate the status of the connection. Is there an elegant way to do this or does it have to be achieved using timers and then monitoring the return of a packet request somehow?
2) I want part of the app functionaliy to allow a user to nominate a specic device address from the scan list, after which that device will automatically be connected when it it is seen in the scan list.
The code has been written to take a focused device address and place it in escrow. When a button is pressed to restart the scan the code compares each device as it is scanned with the device address in escrow. If a match is found the scan continues to completion. Another button is then used to take the escrow address and creates the connection. All this works, but if I move the creation of the connection into the scanning code I end up in horrible issues with null pointers or getting locked in unresolved wait states. I have tried forcing a button click for the button that works, embedding the code into the scan routine or at various places further down line from that point, and even using global flags to try and force it from the main program loop...... all failed with the same problems.
This seems to be because the call to "BLEManager.Connect(new CyConnectInfo(PEER_DEVICE_BD_ADDR, new CyBleConnectionSettings()));" results in a callback to the "BLEManagerCallBack.ConnectionHandler" (which "sets" an essential AutoResetEvent) if the code is run from a Form control event, but not if the routine is called from any other place. I cannot follow the program execution here as it is hidden inside the API. I know this is a bit specific but any general thoughts and or comments might get me started again!
Any and all comments or suggestions very welcome!
Show Lesshi,
SO I tested my hardware with Capsense P4 one Button code. it was working, now I have to modify it for 3 buttons, so from the forum, I have modified the code as follow,
so here is my code:
/* ========================================
*
* 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"
/* Refresh interval in milliseconds for fast scan mode */
#define LOOP_TIME_FASTSCANMODE (30u)
/* Refresh interval in milliseconds for slow scan mode */
#define LOOP_TIME_SLOWSCANMODE (100u)
#define MILLI_SEC_TO_MICRO_SEC (1000u)
#if (!CY_IP_SRSSV2)
/* ILO frequency for PSoC 4 S-Series device */
#define ILO_CLOCK_FACTOR (40u)
#else
/* ILO frequency for PSoC 4 device */
#define ILO_CLOCK_FACTOR (32u)
#endif
/* Refresh rate control parameters */
#define WDT_TIMEOUT_FAST_SCAN (ILO_CLOCK_FACTOR * LOOP_TIME_FASTSCANMODE)
#define WDT_TIMEOUT_SLOW_SCAN (ILO_CLOCK_FACTOR * LOOP_TIME_SLOWSCANMODE)
/* Macro to enable WDT */
#define ENABLE_WDT (0x01u)
/* Macro to disable/enable tuner to update sensor parameters - 0: disable 1: enable */
#define TUNER_UPDATE_ENABLE (0u)
/* This timeout is for changing the refresh interval from fast to slow rate
* The timeout value is WDT_TIMEOUT_FAST_SCAN * SCANMODE_TIMEOUT_VALUE
*/
#define SCANMODE_TIMEOUT_VALUE (150u)
/* Reset value of softCounter */
#define RESET (0u)
/* Boolean constants */
#define TRUE (1u)
#define FALSE (0u)
/* Finite state machine states for device operating states */
typedef enum
{
SENSOR_SCAN = 0x01u, /* Sensor is scanned in this state */
WAIT_FOR_SCAN_COMPLETE = 0x02u, /* CPU is put to sleep in this state */
PROCESS_DATA = 0x03u, /* Sensor data is processed */
SLEEP = 0x04u /* Device is put to deep sleep */
} DEVICE_STATE;
/* Firmware implements two refresh rates for reducing average power consumption */
typedef enum
{
SLOW_SCAN_MODE = 0u,
FAST_SCAN_MODE = 1u
} SCAN_MODE;
/* 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;
/* Variable to store interrupt state */
uint32 interruptState = 0u;
/* 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;
/* Compensated Watchdog match value in fast scan mode */
uint32 wdtMatchValFastMode = 0u;
/* Compensated Watchdog match value in slow scan mode */
uint32 wdtMatchValSlowMode = 0u;
/* Variable to check the WDT interrupt state */
volatile uint8 wdtInterruptOccured = FALSE;
/* Contains watchdog match value to generate period interrupt */
volatile uint32 watchdogMatchValue = WDT_TIMEOUT_FAST_SCAN;
/* API to prepare the device for deep sleep */
void EnterDeepSleepLowPowerMode(void);
/* API to configure the WDT timer for controlling scan intervals */
void WDT_Start(void);
/* API to get WDT matchvalue to generate precise scan intervals */
void CalibrateWdtMatchValue(void);
void scan_process();
int main(void)
{
/* Enable global interrupts for CapSense operation */
CyGlobalIntEnable;
/* Initialize the LED pin as digital output, initially off */
Green_LED_Write( 0 );
Green_LED_1_Write( 0 );
Green_LED_2_Write( 0 );
#if TUNER_UPDATE_ENABLE
/* Start EZI2C block */
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);
#endif
/* Start CapSense block - Initializes CapSense data structure and
* performs first scan of all widgets/sensors to set up sensors
* baselines
*/
CapSense_Start();
/* Configure button sensor parameters and connect it to AMUXBUS */
CapSense_CSDSetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_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();
for(;;)
{
/* Place your application code here. */
scan_process();
}
}
void scan_process()
{
/* 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())
{
/* Update CapSense parameters set via CapSense tuner before the
* beginning of CapSense scan. This check if required if we are using
* CapSense Extension (Ext) APIs in the project.
*/
#if (TUNER_UPDATE_ENABLE)
if(CapSense_STATUS_RESTART_DONE == CapSense_RunTuner())
{
/* Set up sensor */
//CapSense_CSDSetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID);
//CapSense_CSDSetupWidgetExt(CapSense_BUTTON1_WDGT_ID, CapSense_BUTTON1_SNS0_ID);
CapSense_CSDSetupWidgetExt(CapSense_BUTTON2_WDGT_ID, CapSense_BUTTON2_SNS0_ID);
}
#endif
/* Scan widget configured by CSDSetupWidgetExt API */
CapSense_CSDSetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID);
CapSense_CSDScanExt();
while(CapSense_IsBusy());
CapSense_CSDSetupWidgetExt(CapSense_BUTTON1_WDGT_ID, CapSense_BUTTON1_SNS0_ID);
CapSense_CSDScanExt();
while(CapSense_IsBusy());
CapSense_CSDSetupWidgetExt(CapSense_BUTTON2_WDGT_ID, CapSense_BUTTON2_SNS0_ID);
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 scanning 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;
/* process button widget */
/*CapSense_ProcessWidget(CapSense_BUTTON0_WDGT_ID);
CapSense_ProcessWidget(CapSense_BUTTON1_WDGT_ID);
CapSense_ProcessWidget(CapSense_BUTTON2_WDGT_ID);*/
CapSense_ProcessAllWidgets();
if(deviceScanMode == FAST_SCAN_MODE)
{
/* If button is active, reset software counter */
if (CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))
{
// Reset the software counter if any button is active. * /
softCounter = RESET;
// led 1 ON
Green_LED_Write( 1 );
}else if(CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID)){
// Reset the software counter if any button is active.
softCounter = RESET;
// LED 2 ON
Green_LED_2_Write( 1 );
}else if(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)){
// Reset the software counter if any button is active.
softCounter = RESET;
// LED 0 ON
Green_LED_1_Write( 1 );
}
else
{
/* Increment the software counter every LOOP_TIME_FASTSCANMODE if button
* touch is not detected.
*/
softCounter++;
// reset led
Green_LED_Write( 0 );
Green_LED_1_Write( 0 );
Green_LED_2_Write( 0 );
/* 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 = wdtMatchValSlowMode;
#if(CY_IP_SRSSV2)
/* Configure Match value */
CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0, watchdogMatchValue);
#endif
/* Set mode to slow scan mode to scan sensors at LOOP_TIME_SLOWSCANMODE */
deviceScanMode = SLOW_SCAN_MODE;
}
}
}
/* If deviceScanMode is SLOW_SCAN_MODE, perform the following tasks */
else
{
/* If button is active, switch to active mode */
/* if (CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID) ||
CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID) ||
CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)
)*/
if (CapSense_IsAnyWidgetActive())
{
/* If sensor is active in slow-scan mode, skip sleep
* and perform sensor scan
*/
currentState = SENSOR_SCAN;
/* Set watchdog match value to fast scan mode */
watchdogMatchValue = wdtMatchValFastMode;
#if(CY_IP_SRSSV2)
/* Configure Match value */
CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0, watchdogMatchValue);
#endif
/* Change the device mode to fast scan mode to provide fast touch response */
deviceScanMode = FAST_SCAN_MODE;
}
}
break;
case SLEEP:
/* Put the device to deep sleep after each CapSense scan */
EnterDeepSleepLowPowerMode();
/* Start scanning the sensors only if interrupt occurred 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 occurred
*/
if(wdtInterruptOccured)
{
/* Set state to scan sensor after device wakes up from sleep */
currentState = SENSOR_SCAN;
wdtInterruptOccured = FALSE;
}
break;
default:
/*******************************************************************
* Unknown power mode state. Unexpected situation.
******************************************************************/
CYASSERT(0);
break;
} // end switch
}
/*******************************************************************************
* Function Name: EnterDeepSleepLowPowerMode
********************************************************************************
* Summary:
* Put the device to DeepSleep power mode. Reconfigures the Components for
* normal operation after wake-up.
*
* Parameters:
* void
*
* Return:
* void
*
* Theory: Before going to deep sleep, the API checks for any
* I2C activity and waits till the I2C transaction is complete before
* the device is put to deep sleep.
*
* Side Effects: None
*
* Note:
*
*******************************************************************************/
void EnterDeepSleepLowPowerMode(void)
{
/* EZI2C_Sleep routine should be called only after on-going I2C
* transaction is complete
* Enter critical section to lock slave state
*/
interruptState = CyEnterCriticalSection();
#if TUNER_UPDATE_ENABLE
/* Check if I2C is busy. If so, skip deep sleep until I2C is free */
if(!(EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_BUSY))
{
/* Configure slave to be wakeup source */
EZI2C_Sleep();
/* Enter DeepSleep. */
CySysPmDeepSleep();
/* WDT or any I2C communication wakes up device from deep sleep. */
/* Configure slave for active mode operation */
EZI2C_Wakeup();
}
#endif
/* Enable interrupts */
CyExitCriticalSection(interruptState);
}
/******************************************************************************
* Function Name: Timer_Interrupt
*******************************************************************************
*
* Summary:
* Handles the Interrupt Service Routine for the WDT timer.
*
* Parameters:
* None.
*
* Return:
* None.
*
* Theory: The interrupt is cleared on the ISR as watchdog in this project is
* used for timing maintenance only. Match value is updated to maintain
* the loop time.
*
* Side Effects: None
*
* Note:
*
*******************************************************************************/
CY_ISR(Timer_Interrupt)
{
#if (CY_IP_SRSSV2)
/* Clears interrupt request */
CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER0_INT);
#else
/* Clear the watchdog interrupt */
CySysWdtClearInterrupt();
/* WDT match value is updated in order to obtain periodic interrupts */
CySysWdtWriteMatch(CySysWdtReadMatch() + watchdogMatchValue);
#endif /* !CY_IP_SRSSV2 */
/* Set to variable that indicates that WDT interrupt had triggered*/
wdtInterruptOccured = TRUE;
}
/******************************************************************************
* Function Name: WDT_Start
*******************************************************************************
*
* Summary:
* Configures WDT.
*
* Parameters:
* None.
*
* Return:
* None.
*
* Theory: This API unmasks the WDT interrupt to route the interrupt to CPU and
* configures the ISR.
*
* Side Effects: None
*
* Note:
*
*******************************************************************************/
void WDT_Start(void)
{
/* Setup ISR */
WDT_Interrupt_StartEx(Timer_Interrupt);
/* Get the actual match value required to generate a given delay */
watchdogMatchValue = WDT_TIMEOUT_FAST_SCAN;
CalibrateWdtMatchValue();
wdtMatchValFastMode = watchdogMatchValue;
watchdogMatchValue = WDT_TIMEOUT_SLOW_SCAN;
CalibrateWdtMatchValue();
wdtMatchValSlowMode = watchdogMatchValue;
#if (CY_IP_SRSSV2)
/* Configure Match value */
CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0, wdtMatchValFastMode);
/* Set up WDT mode */
CySysWdtSetMode(CY_SYS_WDT_COUNTER0, CY_SYS_WDT_MODE_INT);
/* Automatically reset counter */
CySysWdtSetClearOnMatch(CY_SYS_WDT_COUNTER0, ENABLE_WDT);
CySysWdtResetCounters(CY_SYS_WDT_COUNTER0_RESET);
/* Enable WDT */
CySysWdtEnable(CY_SYS_WDT_COUNTER0_MASK);
#else
/* WDT match value is updated in order to obtain periodic interrupts */
CySysWdtWriteMatch(CySysWdtReadMatch() + watchdogMatchValue);
/* Enable WDT interrupt */
CySysWdtUnmaskInterrupt();
#endif
}
/*******************************************************************************
* Function Name: CalibrateWdtMatchValue
********************************************************************************
* Summary:
* This function calibrates the match value of the Watchdog Timer
*
* Parameter:
* None
*
* Return:
* void
*
* Theory: The ILO is calibrated using IMO to improve the accuracy of ILO.
*
* Side Effects: None
*
* Note:
*
*******************************************************************************/
void CalibrateWdtMatchValue()
{
/* Contains ILO Trimmed value */
uint32 tempIloCounts = 0u;
/* Desired delay in microseconds for ILO Trimming */
uint32 desiredDelay = ((watchdogMatchValue / ILO_CLOCK_FACTOR) * MILLI_SEC_TO_MICRO_SEC);
/* Get the ILO compensated counts i.e. the actual counts for the desired ILO frequency
* Trimming is done to improve ILO accuracy using IMO; ILO default accuracy is +/- 60%
*/
if(CYRET_SUCCESS == CySysClkIloCompensate(desiredDelay, &tempIloCounts))
{
watchdogMatchValue = (uint32)tempIloCounts;
}
}
/* [] END OF FILE */
The problem that I am facing is, I have 3 buttons of which 2 are detected properly, that when I touch led is ON when release OFF, but for 1 button its continuously ON either touch or not, when I debugged I found that the program continuously goes in the below section,
else if(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)){
// Reset the software counter if any button is active.
softCounter = RESET;
// LED 0 ON
Green_LED_1_Write( 1 );
}
for debugging purposes, I changed the button position in GPIO allocation, but the same result either of 1 button from 3 is continuously active. I don't think it is hardware-related, I am looking for help in this section, what could I be doing wrong?
Secondly, I read about the Guard sensor, what I have to do for implementing the guard sensor?
Edit : added project as zip file
Show Less