Dear all,
I'm working on CY8C4245AXI-483 MCU. I want to write a code to toggle LED through capsense touch button. it means, initially LED is OFF. now when i touch button it should be ON. and remains ON untill i touched it 2nd time. after touching 2nd time it should be in OFF condition and remains in OFF untill i touched it 3rd time and so on.
i found code for same, somewhere on internet. is this correct or i need to change something? Please give me your valuable suggestions.
Thanks & Regards,
Prem KB
/*code starts from here*/
uint fingerpresent_0 = 0;
uint8 wdgt_active = 0;
Hi All
I found the NAK Signal During the write frame.
I have attached the logic analyzer observation result for the same.
Master Device:- PIC Controller
Slave Device :- Cy8C4025AZI-S413
My Slave Address is 0x08
Ideally After Address byte their should be ACK From Slave but I observed NAK Signal.
I am not getting where is the exact mistake?
Any help will be highly appreciated.
Regards,
AsDh
Please Find the below Code for reference..
#include <project.h>
/* Macro Declaration */
#define BUFFER_SIZE (1u)
#define PACKET_SIZE (BUFFER_SIZE)
/* The I2C Slave read and write buffers */
uint8 i2cReadBuffer [BUFFER_SIZE] = {0};
uint8 i2cWriteBuffer[BUFFER_SIZE]= {0};
uint8_t flag1=0;
uint8_t flag3=0;
void Received_Data_From_Master1();
int main()
{
/* Eneble Global Interrupt */
CyGlobalIntEnable;
CapSense_Start();
CapSense_ScanAllWidgets();
/* Start the I2C Slave And I2C Address Setting*/
I2CS_I2CSlaveInitReadBuf(i2cReadBuffer, BUFFER_SIZE);
I2CS_I2CSlaveInitWriteBuf(i2cWriteBuffer, BUFFER_SIZE);
I2CS_I2CSlaveSetAddress(0x08);
I2CS_Start();
for (;;)
{
//CyDelay(2);
/* With Respect to Master i.e Checked Whether the Master Write Complted Or Not */
if (0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_CMPLT))
{
/* Calling Function to Collect The Data From Master */
Received_Data_From_Master1();
/* Enable this above function when we used the data On Switch Function */
/* Clear the slave write buffer and status */
I2CS_I2CSlaveClearWriteBuf();
(void) I2CS_I2CSlaveClearWriteStatus();
}
if (0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_CMPLT))
{
/* Clear the slave read buffer and status */
I2CS_I2CSlaveClearReadBuf();
(void) I2CS_I2CSlaveClearReadStatus();
}
if(CapSense_NOT_BUSY == CapSense_IsBusy())
{
/* API For Capsense Update Scanning And Process */
CapSense_ProcessAllWidgets(); /* Process all widgets */
CapSense_RunTuner(); /* To sync with Tuner application */
/* Checked whether Left Button Active or Not*/
if((flag3==0)&&(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)) )
{
POWER_LED_Write(0);
flag3=1; /* Reseting Left Button Flag */
i2cReadBuffer[0] = 0x01;
// while (I2CS_I2C_SSTAT_RD_CMPLT!=(I2CS_I2CSlaveStatus()));
// /* Clear the slave read buffer and status */
// I2CS_I2CSlaveClearReadBuf();
// (void) I2CS_I2CSlaveClearReadStatus();
//i2cReadBuffer[0] = 0xFF;
}
else if((flag3==1) && (!(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID))))
{
flag3=0; /* Setting Left Button Flag */
i2cReadBuffer[0] = 0xFF;
}
/* Checking Right Button active or not */
if((flag1==0)&&(CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID)))
{
flag1=1; /* Reseting the flag*/
i2cReadBuffer[0] = 0x06;
// while (I2CS_I2C_SSTAT_RD_CMPLT!=(I2CS_I2CSlaveStatus()));
// /* Clear the slave read buffer and status */
// I2CS_I2CSlaveClearReadBuf();
// ( void) I2CS_I2CSlaveClearReadStatus();
i2cReadBuffer[0] = 0xFF;
}
else if((flag1==1)&& (!(CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))))
{
flag1=0;
}
CapSense_ScanAllWidgets();
}
}
}
void Received_Data_From_Master1()
{
switch(i2cWriteBuffer[0])
{
/* After Receiving 00 touch will be Ready to Work */
case 0x00:
i2cReadBuffer[0] = 0x19; /*According to New Document Wants to transmit new data acknowledgement */
POWER_LED_Write(0);
break;
}
}
/* [] END OF FILE */
Show Less
Hi All
I found the NAK Signal During the write frame.
I have attached the logic analyzer observation result for the same.
Master Device:- PIC Controller
Slave Device :- Cy8C4025AZI-S413
My Slave Address is 0x08
Ideally After Address byte their should be ACK From Slave but I observed NAK Signal.
I am not getting where is the exact mistake?
Any help will be highly appreciated.
Regards,
AsDh
Show Less
Hello.
Attached project uses 2 PWM components.
PWM makes square wave, and this square wave is stopped or started by PWM_Timer interrupt.
Attached pptx file is waveform of this square wave.
Sometimes it takes some time for voltage level to reach GND when square wave is stopped.
Please confirm red circle of attached pptx file.
Q1)
Could you please let us know reason why this behavior occurs?
Does this behavior occur if PWM is stopped when voltage level is high?
Why doesn't voltage level go to GND immediately?
Q2)
Could you please let us know solution to this behavior?
I want to immediately set voltage level to GND regardless of timing that PWM_stop is called.
Best Regards.
Yutaka Matsubara
Show LessHi All,
I tried to implement I2C communication between Cy8C4025AZI-S412( Slave ) and Pic Microcontroller(Master). The speed is 100kbps and used polling method. When button not pressed then it will sent 0xFF. The polling time is 100msec by PIC controller.
The issue is,
1) Sometimes acknowledge not given by Slave.(need to sent data 3 to 4 times or delay of 30ms then it gives ack ).
I used one example code to develop I2C.
My code is below,
#include <project.h>
/* Macro Declaration */
#define BUFFER_SIZE (1u)
#define PACKET_SIZE (BUFFER_SIZE)
/* The I2C Slave read and write buffers */
uint8 i2cReadBuffer [BUFFER_SIZE] = {0};
uint8 i2cWriteBuffer[BUFFER_SIZE]= {0};
uint8_t flag1=0;
uint8_t flag3=0;
void Received_Data_From_Master1();
int main()
{
/* Eneble Global Interrupt */
CyGlobalIntEnable;
CapSense_Start();
CapSense_ScanAllWidgets();
/* Start the I2C Slave And I2C Address Setting*/
I2CS_I2CSlaveInitReadBuf(i2cReadBuffer, BUFFER_SIZE);
I2CS_I2CSlaveInitWriteBuf(i2cWriteBuffer, BUFFER_SIZE);
I2CS_I2CSlaveSetAddress(0x08);
I2CS_Start();
for (;;)
{
CyDelay(2);
/* With Respect to Master i.e Checked Whether the Master Write Complted Or Not */
if (0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_CMPLT))
{
/* Calling Function to Collect The Data From Master */
Received_Data_From_Master1();
/* Enable this above function when we used the data On Switch Function */
/* Clear the slave write buffer and status */
I2CS_I2CSlaveClearWriteBuf();
(void) I2CS_I2CSlaveClearWriteStatus();
}
if(CapSense_NOT_BUSY == CapSense_IsBusy())
{
/* API For Capsense Update Scanning And Process */
CapSense_ProcessAllWidgets(); /* Process all widgets */
CapSense_RunTuner(); /* To sync with Tuner application */
/* Checked whether Left Button Active or Not*/
if((flag3==0)&&(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)) )
{
flag3=1; /* Reseting Left Button Flag */
i2cReadBuffer[0] = 0x01;
while (I2CS_I2C_SSTAT_RD_CMPLT!=(I2CS_I2CSlaveStatus()));
/* Clear the slave read buffer and status */
I2CS_I2CSlaveClearReadBuf();
(void) I2CS_I2CSlaveClearReadStatus();
i2cReadBuffer[0] = 0xFF;
}
else if((flag3==1) && (!(CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID))))
{
flag3=0; /* Setting Left Button Flag */
i2cReadBuffer[0] = 0xFF;
}
/* Checking Right Button active or not */
if((flag1==0)&&(CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID)))
{
flag1=1; /* Reseting the flag*/
i2cReadBuffer[0] = 0x06;
while (I2CS_I2C_SSTAT_RD_CMPLT!=(I2CS_I2CSlaveStatus()));
/* Clear the slave read buffer and status */
I2CS_I2CSlaveClearReadBuf();
( void) I2CS_I2CSlaveClearReadStatus();
i2cReadBuffer[0] = 0xFF;
}
else if((flag1==1)&& (!(CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))))
{
flag1=0;
}
}
}
}
void Received_Data_From_Master1()
{
switch(i2cWriteBuffer[0])
{
/* After Receiving 00 touch will be Ready to Work */
case 0x00:
i2cReadBuffer[0] = 0x19; /*According to New Document Wants to transmit new data acknowledgement */
POWER_LED_Write(0);
break;
}
}
Any Help will be highly appreciated .
Thanks & Regards,
AsDh
Show Less
Hello,
I have two Cy8C-042 Evaluation boards. I want to synchronize them.
They shared two GPIOs over optocouplers. 1 is the output of 1 and input of other and other ist input of 1 and output of other.
There is a test I have to perform for 10ms. for 1ms microcontroller but i cannot be able to synchronize them 100 percent.
at the start of the test, they are almost synchronized but later at the end of test they have a difference of around 200 to 300 uS.
Can somebody help me to figure out the problem?
In my application Psoc4 has to serve a device that could be configured in SPI or parallel mode during runtime. In SPI mode pin named D0 has to be configured as MTSR, D1 has to be configured as SS, D2 has to be configured as SCLK and D3 has to be configured as MRST. In parallel mode D0...D3 are part of the parallel IO (D0...D7) offering bidirectional IO. How to implement this switch on the fly?
Show LessI've been learning how to use PSoC by the tutorial vids. In lesson 4 I encountered a problem, when it came to the hardware connection between the switch and the LED.
The error is: "Pin guidance unavailable. Pin cannot be placed at X. Pin cannot be used for routed connections." for both the input and the output pin as soon as i connect them by wire in my TopDesign.
The goal would be to directly turn on the LED by pressing the switch as described in the tutorial.
Is this a configuration problem or is my board not able to do hardware connections (which I doubt).
I'm using PSoC Creator 4.4 and the CY8CKIT-149 PSoC 4100S Plus Prototyping Kit, CY8C4147AZI-S47564.
I attached the project.
I'd be very grateful for an explanation of this error and even more for a solution.
Show LessPSoC Creator怎么确认堆栈是否足够,当前堆栈的使用情况?
使用PSoC4开发的时候发现ROM不够了,想做下优化,PSoC Creator有没有内存对齐方式的设置,比如说把对齐方式从4Byte改为2Byte?
Expert II
Esteemed Contributor
Employee
Honored Contributor II
Employee
Employee
Honored Contributor II
Employee