PSoC™ 4 Forum Discussions
text.format{('custom.tabs.no.results')}
Hi,
I've got a PRoC 4 EZ-BLE working as a peripheral server in a custom profile mode. I have a function that reads the CyBle_GetRssi() value and stores it in a custom service in the GATT DB. The client (phone or CySmart) reads this value to see what the received RSSI was on the peripheral. I can't seem to make sense of the value that gets stored, it seems out of bounds for the API. The API says it gives a range from -85-5 dBm, but the value I am reading on CySmart is often times around 2C, which is equivalent to 44dBm. Also, the value will sometimes jump to some value not even close to what it was before, an erroneous reading.
Please help me to understand what the CyBle_GetRssi() function is actually returning, or possibly my code is not storing it correctly.
Also, I am running PSoC Creator 3.2.0.6175. I will be upgrading to 3.3 today.
Here's my code:
In my main function, every loop (after wakeup from sleep), I call this function
void UpdateRSSIValue()
{
/* Read the last known RSSI Value */
/* I dont understand the value completely. Also, it is an int, but the handle.value.val
* below is a uint, how does that affect the value?
*/
static int8 rssiValue = 0;
rssiValue = CyBle_GetRssi();
/* Save the RSSI Value to the GATT db */
CYBLE_GATT_ERR_CODE_T gattResult;
CYBLE_GATT_HANDLE_VALUE_PAIR_T rssiHandle;
rssiHandle.attrHandle = RSSI_CHAR_HANDLE;
rssiHandle.value.val = &rssiValue;
rssiHandle.value.len = 1;
gattResult = CyBle_GattsWriteAttributeValue(&rssiHandle, FALSE, &cyBle_connHandle, FALSE);
/* Check if the db was successfully updated */
if(gattResult != CYBLE_GATT_ERR_NONE)
{
Green_LED_SetDriveMode(Green_LED_DM_STRONG); //Constant on LED indicates a failure
CYASSERT(0);
}
}
Here's my main loop for completeness:
int main()
{
/*Initialize System */
InitializeSystem();
CYBLE_LP_MODE_T lpMode;
CYBLE_BLESS_STATE_T blessState;
uint8 connIntervalCount = 0;
CyGlobalIntEnable;
for(;;)
{
/* Set the lowest possible power mode. First check the state of the BLE. If it's not
* initializing, try to set the lowest power mode based on what's allowable by the
* current bless state. If the BLE is in deep sleep, the Bless is in deep sleep or
* ECO_ON state, AND the timers are all off (Alert levels are off and LLS timer
* is not running), then put the CPU into deep sleep. Otherwise go into sleep.
*/
if(CyBle_GetState() != CYBLE_STATE_INITIALIZING)
{
/* Enter DeepSleep mode between connection intervals */
lpMode = CyBle_EnterLPM(CYBLE_BLESS_DEEPSLEEP);
blessState = CyBle_GetBleSsState();
if(lpMode == CYBLE_BLESS_DEEPSLEEP)
{ /* CPU system is capable of entering deep sleep */
if(blessState == CYBLE_BLESS_STATE_ECO_ON || blessState == CYBLE_BLESS_STATE_DEEPSLEEP)
{
/* If the timers are not active, go into deep sleep */
if(CheckTimerStates() == TIMERS_OFF)
{
CySysPmDeepSleep();
}
/* Otherwise go into sleep to keep timers active */
else
{
CySysPmSleep();
}
}
}
else
{
if(blessState != CYBLE_BLESS_STATE_EVENT_CLOSE)
{
CySysPmSleep();
}
}
}
/* Try processing events here. The downside is everything will be 1 interval
* behind, but hopefully i can improve rssi data */
CyBle_ProcessEvents();
/* Once the system wakes up from the BLE timer,
* process the routine functions as well as the BLE Events */
if(CyBle_GetState() == CYBLE_STATE_CONNECTED)
{
/* Update the last known RSSI Value in the GATT db */
UpdateRSSIValue();
/* Check the status of the CapSense Pads ONLY if the user wants an alarm for them.
* Otherwise don't check so we can save time and power */
if(cssAlertLevel != 0)
{
UpdateCapSense(FALSE);
}
/* For some reason I can't get the system to use the bas register callback
* Therefor, temporarily, I will just measure the battery level every 'X'
* number of connection intervals. This should be fixed at a later date!!
*/
if(connIntervalCount++ == MEAS_BAT_INTERVAL)
{
connIntervalCount = 0;
(void) MeasureBattery();
}
}
/* If the device is not connected but the BLE is active, update
* the advertisement data to broadcast the current alert level
*/
else if(CyBle_GetBleSsState() == CYBLE_BLESS_STATE_ACTIVE)
{
UpdateAdvertisementData();
}
/* Things worked when I had process events here, but lets try moving it up to get better rssi data */
//CyBle_ProcessEvents();
}
}
Hi
I am using CYBLE 224110 EVAL for my project. In this project we are making a device which uses rechargeable battery. I also created a charge circuit for this device to work. When the device is put on the charging station it will be powered by directly from supply and the connection from battery to circuit is terminated.. But as soon as we take the device from charging station it will be powered by battery.
TPS78230DDCT voltage regulator and BQ24072 this charging IC.
The VBAT is connected to voltage regulator and then from voltage regulator it is powering PSOC. When it is disable then will the PSOC still draw current from battery?
Show LessLet there be interrupts configured with multiple priorities. If high-priority interrupt is to be executed while the low-priority interrupt is executing, CM0 nests the interrupts, pre-empts the low-priority interrupt and executes the high-priority one.
Now, the question - we would like to decide in high-priority interrupt whether we want to return the execution to the low-priority interrupt or skip/disable it. Is this possible?
Would changing the LR from 0xFFFFFFF1
to 0xFFFFFFF9 and taking data off the stack do it?
Hello,
I have one simple programm see attached "main1.c" that works properly, respectively I can read with Master the EZI2C-Buffer without problems:
But than I have a second program with a little bit more code "main2.c" but in fact the same - and there I cannot read the EZI2C-Buffer.
I only get always 0 values, except I stop CapSense before give a Value to the buffer.
I am very confused, and I don't know, see why with main1.c it works but with main2.c it not works??
It would be very appreciate if anybody could help or point me to an solution....?
thank you very much
main1.c
#include "project.h"
uint8 reg[20]={0};
uint8 diff=0;
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
EZI2C_EzI2CSetBuffer1(sizeof(reg), 1, (uint8 *)®);
EZI2C_Start();
CapSense_Start();
CapSense_ScanAllWidgets();
while(CapSense_IsBusy()){}
CapSense_InitializeAllBaselines();
for(;;)
{
/* Place your application code here. */
CapSense_ScanAllWidgets();
while(CapSense_IsBusy()){}
CapSense_ProcessAllWidgets();
diff=CapSense_BUTTON0_SNS0_DIFF_VALUE;
Pin_1_Write(1u);
//Pin_2_Write(1u);
CyDelay(1u);
Pin_1_Write(0u);
//Pin_2_Write(0u);
CyDelay(1u);
//CyDelay(1000u);
//CapSense_Stop();
reg[1]=diff;
//CapSense_Start();
}
}
/* [] END OF FILE */
main2.c (based on example CE210291_CapSense_P4_One_Button01)
int main()
{
....
/* Start EZI2C block */
EZI2C1_EzI2CSetBuffer1(sizeof(reg), 1, (uint8 *)®);
EZI2C1_Start();
....
CapSense_Start();
...
WDT_Start();
for(;;)
{
/* Switch between sensor-scan -> wait-for-scan -> process -> sleep states */
switch(currentState)
{
case SENSOR_SCAN:
...
/* 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());
....
.....
break;
case WAIT_FOR_SCAN_COMPLETE:
...
break;
case PROCESS_DATA:
interrupt_Write(0u);
/* Set next state to SLEEP */
currentState = SLEEP;
/* process button widget */
CapSense_ProcessWidget(CapSense_BUTTON0_WDGT_ID);
CapSense_ProcessWidget(CapSense_BUTTON1_WDGT_ID);
....
if( counts < CapSense_BUTTON0_SNS0_DIFF_VALUE)
{counts = CapSense_BUTTON0_SNS0_DIFF_VALUE; button = 0;}
if( counts < CapSense_BUTTON1_SNS0_DIFF_VALUE)
{counts = CapSense_BUTTON1_SNS0_DIFF_VALUE; button = 1;}
if( counts < CapSense_BUTTON2_SNS0_DIFF_VALUE)
{counts = CapSense_BUTTON2_SNS0_DIFF_VALUE; button = 2;}
....
...
if( counts < 11)
{button = 10;}
//else{interrupt_Write(0u);}
//CapSense_Stop();
//while(CapSense_IsBusy()){}
if(button == 0) {reg[9]=1; Pin_1_Write(0u); Pin_2_Write(1u); Pin_3_Write(1u); Pin_4_Write(1u); Pin_5_Write(1u); Pin_6_Write(1u); Pin_7_Write(1u); Pin_8_Write(1u); counts=10;}
else if(button == 1){reg[9]=2; Pin_2_Write(0u); Pin_1_Write(1u); Pin_3_Write(1u); Pin_4_Write(1u); Pin_5_Write(1u); Pin_6_Write(1u); Pin_7_Write(1u); Pin_8_Write(1u); counts=10;}
else if(button == 2){reg[9]=3; Pin_3_Write(0u); Pin_1_Write(1u); Pin_2_Write(1u); Pin_4_Write(1u); Pin_5_Write(1u); Pin_6_Write(1u); Pin_7_Write(1u); Pin_8_Write(1u); counts=10;}
....
...
...
else if(button == 10){reg[9]=0; Pin_1_Write(1u); Pin_2_Write(1u); Pin_3_Write(1u); Pin_4_Write(1u); Pin_5_Write(1u); Pin_6_Write(1u); Pin_7_Write(1u); Pin_8_Write(1u); counts=10;}
//CapSense_Start();
...
break;
case SLEEP:
...
break;
}
}
}
*******************************************************************************/
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();
/* Check if I2C is busy. If so, skip deep sleep until I2C is free */
if(!(EZI2C1_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_BUSY))
{
/* Configure slave to be wakeup source */
EZI2C1_Sleep();
/* Enter DeepSleep. */
CySysPmDeepSleep();
/* WDT or any I2C communication wakes up device from deep sleep. */
/* Configure slave for active mode operation */
EZI2C1_Wakeup();
}
/* Enable interrupts */
CyExitCriticalSection(interruptState);
}
....
Show LessI am detecting a voltage (present or not) from 5V USB connector. The measured voltage with plug connected is 5V in to a resistive divider.
The series resistor is 1k and 10k to ground with 1 100n cap across the 10k and also a 3V zener.
In creator I have set the pin to High Impedance. The voltage of the divider should be around 3V (4.5V is output but it should be clamped by the Zener to around 3V).
However, when I measure the voltage I only see 2.6V?
The pin being used is P4.0 and I have it creating an interrupt on change (high or low).
Show LessHi,
I am working with the CYBLE-224116 extended range PSoC4/BLE module. The module works great, however I am having a problem getting it to sleep the way the other PSoC4 devices do.
With my other PSoC4 devices such as the CYBLE-014008, when I put the device into deep sleep, the power consumption follows the specification of 1.3uA.
With this new CYBLE-224116 module, I am seeing a current draw of about 1.3mA @ 3.3V. The only components I have attached to this module is a red and blue LED on pins P1[0] and P0[1] and a 1uF capacitor on VREF to ground. I will attach the project to this thread as well so you can see that as well. Below is my main.c which I am using to evaluate the module's low power. Any thoughts would be greatly appreciated.
Thanks.
- Chris
#include "project.h"
#define CYREG_SRSS_TST_DDFT_CTRL 0x40030008
int main(void)
{
// Variables
uint8 intrStatus;
// Enable interrupts
CyGlobalIntEnable;
// Turn on the red LED for startup
LED_RED_Write(1);
LED_BLUE_Write(0);
// Startup code
CyDelay(500);
// Disable the PA/LNA
CY_SET_XTND_REG32((void CYFAR *)(CYREG_BLE_BLESS_RF_CONFIG), 0x0331);
CY_SET_XTND_REG32((void CYFAR *)(CYREG_SRSS_TST_DDFT_CTRL), 0x80000302);
CSD_Write(0);
CPS_Write(0);
// Turn off the LEDs
LED_RED_Write(0);
LED_BLUE_Write(0);
for(;;)
{
// Turn on the blue LED for 500 ms
LED_BLUE_Write(1);
CyDelay(500);
LED_BLUE_Write(0);
// Sleep the processor
intrStatus = CyEnterCriticalSection();
CySysPmDeepSleep();
CyExitCriticalSection(intrStatus);
}
}
Show LessHi,
The customer considers to use Low-Power CapSense Design As described in AN210998.
If he needs three buttons, what is the power consumption?
I have two ideas.
1)
2)
Which is correct?
I think that this may be misunderstood.
Please teach the correct answer.
Best Regards,
Inoue
Show LessIs there a document of PSoC4 startup procedure(like AN60616 about Psoc3 and 5LP)?
If No, please let me know the startup procedure simply.
Best Regards,
Inoue
Show LessI wired up P4.0 to analog input and found the 4200 only allows ADC on Port 2 (0..7) and thought I'd ask the question before re-laying up my PCB.
Is there any way to use a comparator or voltage monitor on this pin? I do not need the actual voltage but I need to generate a signal when battery falls below a certain value. (Like the LVD interrupt but I need it on the battery and not the micro supply voltage).
Thanks
Show LessMy project has a couple of thermistors along with a few other analog values that need monitoring. All associated pins are high-Z Analog inputs with high initial drive (tried both), fed into a ADC_SAR_SEQ_P4_v2_50.
Now, I thought this would be a slam-dunk. I followed a number of examples - most of them agreed, so I made my project look like those.
But after starting a conversion and waiting for completion, I don't see any meaningful change in the data. I can measure voltage where the thermister comes into the board, and it is indeed changing.
I thought perhaps I needed external terminal for the pins, but it didn't seem to matter, and other examples don't typically use it. I'm not using a hardware trigger - documentation for ADC_Start() indicates it's a substitute ( ADC_FW_TRIGGER), and ADC_IsEndConversion() seems entirely happy.
I've uploaded an archive of the case where there are no external terminals for the pins, though that doesn't seem to matter.
I am in a quandary - can anyone tell me what bit I have messed up?
Thanks,
John