PSoC™ 4 Forum Discussions
I've tried building and running both the version described in AN97060 as well as the one described in BLE Upgradable Stack Example Projects. I've been able to configure, compile and download both versions but have been unsuccessful in being able to do an OTA update. Using CySmart to do the update, it takes quite a while after starting the update to get past the 'Establish Connection' point, then times out at 'Exchange GATT MTU'. I realize it's probably something I've overlooked, but is there a simple complete example project available somewhere. Also I'd be interested to know if the CySmart default 'Master Settings' need to be modified.
Thanks
-Bill K
Show LessHello,
I got this BLE module- http://www.usriot.com/p/ble-modules/ which uses CYBL10162-56LQXI.
Currently I am using arduino to communicate with BLE module.
I am successful in entering AT mode and also changing parameters of BLE.
However I am unable to pair with my android device (android version-6.0.1).
While pairing it says "pairing rejected by BLE-USR-100".
Are there any specific configuration which need to set for BLE?
I would also like to program BLE such that when the BLE receive a specific character from a user device (server- mobile application), BLE should pull one of the GPIO pins to LOW state. I am newbie to BLE programming. Please guide me from where do I start. Is there any specific example code available?
Please help.
Thanks
Show LessI'm using the CY8C4247AZI-M485. I want to use the IDAC component with the DMA to generate a sine wave. I believe I have everything set up correctly but it's not working. In the "DMA Support" section of the IDAC datasheet it states the following:
Note DMA support in the IDAC_P4 component is limited due to the following reasons:
The IDAC_1_IDAC_CONTROL register is common for two IDACs (8-bit IDAC and 7-bit IDAC).
The IDAC_1_IDAC_CONTROL register is common for the IDAC setting and IDAC data.
Before using the DMA channel with the IDAC_P4 component, review the description of this register in the device registers Technical Reference Manual (TRM).
I've searched for "IDAC_CONTROL" in the TRM but couldn't find anything.
Can someone tell me if this is even possible with this PSOC? If so, what am I doing wrong?
Show LessHi,
I've written a simple program to test the BLE notifications.
This will update a counter every 2 seconds.
After about 20-24 seconds with connection is lost.
I've attached my code, if someone could have a look and tell me where i'm going wrong.
kind regard,
Damian
Show LessI have run the client bonding example from project #15 of 100 days of code, however I am designing a server with no display and no keypad, and i want it to pair/bond to android app so user doesnt have to keep manually manipulating the andrio app to see the device, according to debug uart printing to tera term the device does:
GAP_SMP_NEGOTIATED_AUTH_INFO: 33
CYBLE_EVT_GAP_AUTH_REQ: security=0x3, bonding=0x1, ekeySize=0x10, err=0x0
GAP_CONNECTION_UPDATE_COMPLETE: 2a
GAP_ENCRYPT_CHANGE: 29
GAP_KEYINFO_EXCHNGE_CMPLT 2c
Authentication Complete
CYBLE_EVT_PENDING_FLASH_WRITE
Store bonding data, PENDING status: 28
GAP_CONNECTION_UPDATE_COMPLETE: 2a
Yet if I exit the app and re enter the app, either the pairing data is not being recovered, or the previous flash write did not execute properly.
similarily, if I use the Cysmart PC application, I can connect, then pair, then discover all attributes, and enable all attributes, and if I disconnect, there is a key stored in the connections white list, but when I try to reconnect, pairing fails, because it tries to use a different key.
So I was wondering if others are seeing this, OR is there an example project where this works properly? I have not been through all the example codes,
Show LessI am trying to save, and read back, the device name from flash without success. I am using this code:
/* Flash Config */
#define FLASH_SIZE 128
/* Flash constants */
#define FLASH_ROW_SIZE_BYTES 128
#define FLASH_ALIGNED __attribute__ ((aligned (FLASH_ROW_SIZE_BYTES)))
static const char FLASH_DEVICE_NAME[FLASH_SIZE] = {0}; // Flash space for device name
char device_name[FLASH_SIZE]; // User input device name
/* Flash data write constants */
#define FLASH_DATA_BASE_ADDRESS_BYTE (uint32) (&FLASH_DEVICE_NAME)
#define FLASH_DATA_BASE_ADDRESS_ROW FLASH_DATA_BASE_ADDRESS_BYTE / FLASH_ROW_SIZE_BYTES
void ReadNameInFlash()
{
uint8 i;
// Read device from Flash
for (i = 0; i < FLASH_SIZE; i++) {
device_name = FLASH_DEVICE_NAME;
}
//CyBle_GapSetLocalName(device_name);
}
void SaveNameInFlash(const uint8 device_name[])
{
CySysFlashSetWaitCycles(48);
CySysFlashWriteRow(FLASH_DATA_BASE_ADDRESS_ROW, device_name);
// CyBle_GapSetLocalName((const char *)device_name);
}
I have commented out the CyBLE calls as the BLE stack is not initialized at this point. The call to CySysFlashWriteRow results in a return code of CY_SYS_FLASH_SUCCESS.
The read of flash returns all zeros....
Thanks for the help.
Rich
Show LessBelow is the main.c portion of two programs that I've combined and included in the uploaded project that I'm having trouble with. The two programs are a ble demo app that shows capsense data and the other is a larger project that grabs i2s data from a mpu-6050. Both of these programs work independently. The program that I've included has the portion where it grabs the I2C data commented out and the ble and capsense work as expected. If I try to grab the i2c data the ble seams to work but the capsense stops updating. Also if I just try to serial data out the capsense stops working. I think it might be an interrupt problem but my programming skills are weak...
The device I am using is a CYBLE-222005 I'm pretty sure I have the pins defined correctly. I'm using a PSOC 4 042 BLE dev kit.
Any help would be greatly appreciated.
/******************************************************************************
* Project Name : PRoC_BLE_CapSense_Proximity
* File Name : main.c
* Version : 1.0
* Device Used : CYBL10563-56LQXI
* Software Used : PSoC Creator 3.3 SP1
* Compiler : ARM GCC 4.9.3, ARM MDK Generic
* Related Hardware : CY8CKIT-042-BLE Bluetooth Low Energy Pioneer Kit
* Owner : ROIT
*
********************************************************************************
* Copyright (2015-16), Cypress Semiconductor Corporation. All Rights Reserved.
********************************************************************************
*
* Use of this Software may be limited by and subject to the applicable Cypress
* software license agreement.
*******************************************************************************/
******************************************************************************/
#include <main.h>
#include <project.h>
#include "mpu6050.h"
#include <stdio.h>
void I2CReadBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *value) {
uint8_t i=0;
I2C_MPU6050_I2CMasterSendStart(devAddr, I2C_MPU6050_I2C_WRITE_XFER_MODE);
I2C_MPU6050_I2CMasterWriteByte(regAddr);
I2C_MPU6050_I2CMasterSendRestart(devAddr, I2C_MPU6050_I2C_READ_XFER_MODE);
while (i++ < (length-1)) {
*value++ = I2C_MPU6050_I2CMasterReadByte(I2C_MPU6050_I2C_ACK_DATA);
}
*value = I2C_MPU6050_I2CMasterReadByte(I2C_MPU6050_I2C_NAK_DATA);
I2C_MPU6050_I2CMasterSendStop();
}
void I2CReadByte(uint8_t devAddr, uint8_t regAddr, uint8_t *value) {
I2CReadBytes(devAddr, regAddr, 1, value);
}
void I2CReadBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *value) {
uint8_t mask = ((1 << length) - 1) << (bitStart - length + 1);
I2CReadByte(devAddr, regAddr, value);
*value &= mask;
*value >>= (bitStart - length + 1);
}
void I2CReadBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *value) {
I2CReadByte(devAddr, regAddr, value);
*value = *value & (1 << bitNum);
}
void I2CWriteBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *value) {
uint8_t i=0;
I2C_MPU6050_I2CMasterSendStart(devAddr, I2C_MPU6050_I2C_WRITE_XFER_MODE);
I2C_MPU6050_I2CMasterWriteByte(regAddr);
while (i++ < length) {
I2C_MPU6050_I2CMasterWriteByte(*value++);
}
I2C_MPU6050_I2CMasterSendStop();
}
void I2CWriteByte(uint8_t devAddr, uint8_t regAddr, uint8_t value) {
I2CWriteBytes(devAddr, regAddr, 1, &value);
}
void I2CWriteBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t value) {
uint8_t b;
uint8_t mask = ((1 << length) - 1) << (bitStart - length + 1);
I2CReadByte(devAddr, regAddr, &b);
value <<= (bitStart - length + 1);
value &= mask;
b &= ~(mask);
b |= value;
I2CWriteByte(devAddr, regAddr, b);
}
void I2CWriteBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t value) {
uint8_t b;
I2CReadByte(devAddr, regAddr, &b);
b = (value != 0) ? (b | (1 << bitNum)) : (b & ~(1 << bitNum));
I2CWriteByte(devAddr, regAddr, b);
}
void I2CWriteWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *value) {
uint8_t i=0;
I2C_MPU6050_I2CMasterSendStart(devAddr, I2C_MPU6050_I2C_WRITE_XFER_MODE);
I2C_MPU6050_I2CMasterWriteByte(regAddr);
while (i++ < length) {
I2C_MPU6050_I2CMasterWriteByte(((uint8_t)*value) >> 8);
I2C_MPU6050_I2CMasterWriteByte((uint8_t)*value++);
}
I2C_MPU6050_I2CMasterSendStop();
}
void I2CWriteWord(uint8_t devAddr, uint8_t regAddr, uint16_t value) {
I2CWriteWords(devAddr, regAddr, 1, &value);
}
/*'deviceConnected' flag is used by application to know whether a Central device
* has been connected. This is updated in BLE event callback */
extern uint8 deviceConnected;
/*'startNotification' flag is set when the central device writes to CCC (Client
* Characteristic Configuration) of the CapSense proximity characteristic to
* enable notifications */
extern uint8 startNotification;
/* 'restartAdvertisement' flag is used to restart advertisement */
extern uint8 restartAdvertisement;
/* 'initializeCapSenseBaseline' flag is used to call the function once that initializes
* all CapSense baseline. The baseline is initialized when the first advertisement
* is started. This is done so that any external disturbance while powering the kit does
* not infliuence the baseline value, that may cause wrong readings. */
uint8 initializeCapSenseBaseline = TRUE;
/*******************************************************************************
* Function Name: main
********************************************************************************
* Summary:
* System entrance point. This calls the BLE routine functions as well as
* function for handling CapSense Proximity changes
*
* Parameters:
* void
*
* Return:
* int
*
*******************************************************************************/
int main()
{
int16_t ax, ay, az;
int16_t gx, gy, gz;
char buf[30];
I2C_MPU6050_Start();
SERIAL_Start();////////////////////////////////////////////////////////////////////////////////
CyGlobalIntEnable;
MPU6050_init();
MPU6050_initialize();
SERIAL_UartPutString(MPU6050_testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
/* This function will initialize the system resources such as BLE and CapSense */
InitializeSystem();
for(;;)
{
/* MPU6050_getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
SERIAL_UartPutString("a/g:\t");
sprintf(buf, "%d \t", ax);
SERIAL_UartPutString(buf);
sprintf(buf, "%d \t", ay);
SERIAL_UartPutString(buf);
sprintf(buf, "%d \t", az);
SERIAL_UartPutString(buf);
sprintf(buf, "%d \t", gx);
SERIAL_UartPutString(buf);
sprintf(buf, "%d \t", gy);
SERIAL_UartPutString(buf);
sprintf(buf, "%d \t", gz);
SERIAL_UartPutString(buf);
SERIAL_UartPutString("\n\r");
*/
/*Process Event callback to handle BLE events. The events generated and
* used for this application are inside the 'CustomEventHandler' routine*/
CyBle_ProcessEvents();
/* Function to handle LED status depending on BLE state */
HandleStatusLED();
/* Handle proximity data and CCCD value update only if BLE device is connected */
if(TRUE == deviceConnected)
{
/* After the connection, send new connection parameter to the Client device
* to run the BLE communication on desired interval. This affects the data rate
* and power consumption. High connection interval will have lower data rate but
* lower power consumption. Low connection interval will have higher data rate at
* expense of higher power. This function is called only once per connection. */
UpdateConnectionParam();
/* If CapSense Initialize Baseline API has not been called yet, call the
* API and reset the flag. */
if(initializeCapSenseBaseline)
{
/* Reset 'initializeCapSenseBaseline' flag*/
initializeCapSenseBaseline = FALSE;
/* Initialize all CapSense Baseline */
CapSense_InitializeAllBaselines();
}
/* Send proximity data when notifications are enabled */
if(startNotification == CCCD_NTF_BIT_MASK)
{
if(CYBLE_BLESS_STATE_ECO_STABLE ==CyBle_GetBleSsState())
{
/*Check for CapSense proximity change and report to BLE central device*/
HandleCapSenseProximity();
SERIAL_UartPutString("a/g:\t");
}
}
}
#ifdef ENABLE_LOW_POWER_MODE
/* Put system to Deep sleep, including BLESS, and wakeup on interrupt.
* The source of the interrupt can be either BLESS Link Layer in case of
* BLE advertisement and connection or by User Button press during BLE
* disconnection */
HandleLowPowerMode();//////////////////////////////////////////////////////////////////////////////////
#endif
if(restartAdvertisement)
{
/* Reset 'restartAdvertisement' flag*/
restartAdvertisement = FALSE;
/* Start Advertisement and enter Discoverable mode*/
CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
}
} /* This is end of for(;;) */
}
/*******************************************************************************
* Function Name: InitializeSystem
********************************************************************************
* Summary:
* Starts the components and initializes CapSense baselines
*
* Parameters:
* void
*
* Return:
* void
*
*******************************************************************************/
void InitializeSystem(void)
{
/* Enable global interrupt mask */
CyGlobalIntEnable;
/* Start BLE component and register the CustomEventHandler function. This
* function exposes the events from BLE component for application use */
CyBle_Start(CustomEventHandler);
/* Set drive mode of the status LED pin to Strong*/
Status_LED_SetDriveMode(Status_LED_DM_STRONG);
#ifdef CAPSENSE_ENABLED
/* Enable the proximity widget explicitly and start CapSense component.
* Initialization of the baseline is done when the connection happens */
CapSense_EnableWidget(CapSense_PROXIMITYSENSOR0__PROX);
CapSense_Start();
#endif
/* Start the Button ISR to allow wakeup from sleep */
isr_button_StartEx(MyISR);
}
/*******************************************************************************
* Function Name: HandleCapSenseProximity
********************************************************************************
* Summary:
* Read the proximity data from the sensor and update the BLE
* custom notification value.
*
* Parameters:
* void
*
* Return:
* void
*
*******************************************************************************/
void HandleCapSenseProximity(void)
{
#ifdef CAPSENSE_ENABLED
/* Static variable to store last proximity value */
static uint8 lastProximityValue = MAX_PROX_VALUE;
/* 'proximityValue' stores the proximity value read from CapSense component */
uint8 proximityValue;
/* Scan the Proximity Widget */
CapSense_ScanWidget(CapSense_PROXIMITYSENSOR0__PROX);
/* Wait for CapSense scanning to be complete. This could take about 5 ms */
while(CapSense_IsBusy())
{
#ifdef ENABLE_LOW_POWER_MODE
/* While CapSense is scanning, put CPU to sleep to conserve power */
CySysPmSleep();/////////////////////////////////////////////////////////////////////////////
#endif
}
/* Update CapSense Baseline */
CapSense_UpdateEnabledBaselines();
/* Get the Diffcount between proximity raw data and baseline */
proximityValue = CapSense_GetDiffCountData(CapSense_PROXIMITYSENSOR0__PROX);
/* Check if the proximity data is different from previous */
if(lastProximityValue != proximityValue)
{
/* Send the proximity data to BLE central device by notifications*/
SendDataOverCapSenseNotification(proximityValue);
/* Update present proximity value */
lastProximityValue = proximityValue;
}
#endif
}
/* [] END OF FILE */
Show LessHello,
I developed project for CY8C4146AZI-S423 but I cannot write it to flash using SWD programmer Miniprog3, because on the form "Select Debug Target" of PSoC Creator this chip do not shown. If I try to use PSoC Programmer, the same result - fields "Device Family" and "Device" are not accessible. I try to use Bootloader made my project bootable and using SW1 connected to P0[7] and pressed it before powering the device, but "Bootloader Host" of PSoC Creator told me "Unable read data from the target device". My project developed in PSoC Creator 4.0 Update 1 and I am using PSoC Programmer 3.25.0. The previous device I used is CY8C4125AZI-483 and the device successfully programmed via Miniprog3 and Bootloader with the same project.
Is there any way to program CY8C4146AZI-S423 device?
Thanks in advance
Show LessHello,
if i load a new firmware to my pSoC4 sometimes a connected I2C-Slave hang (SDA is low).
I have to disconnect the power to reset the slave.
Can i reset the I2C Bus from the master?
Günter
Show LessHello , I would like to stop i2c communication during runtime and use the scl pin to toggle several times to reset a slaves State Machine. It seems that calling the SCL_Stop() function is not enough to get the scl pin back to normal output function. Here is my code: I2C_Stop(); /* Stop I2C */ I2C_scl_SetDriveMode(I2C_scl_DM_STRONG); /*set DriveMode*/ I2C_scl_Write( 1u ); /*set pin output manually*/
Show Less