PSoC™ 4 Forum Discussions
Hi All,
Is there an example source code for I2C master using Interrupt?
Please refer to below.
- IDE : PSoC Creator 4.2
- PSOC4200L
- I2C SCB
- I2C Master example using interrupt
a. transfer
When the Tx start interrrupt flag is triggered, then I2C ISR starts transferring rest of the data.
b. receive
If there is data in the I2C rx buffer, then the data is transferred from I2C Rx FIFO to the user defined buffer by the ISR.
Thanks and Regards,
YS
Show LessI used Cy8CKIT-040 and Cy8CKIT-024 for proximity induction, but since 024 is a hard PCB, I now want to make the sensor (including the shielded electrode) a flexible material so that it can be used in more applications.
Is this idea feasible?
Are there any other ways besides using FPC, a flexible circuit board?
best regards!
Show LessOur application ( Fast-mode : 400Khz) the measured fall time is only about 4ns - but I2C spec's the minimum allowed fall time according the spec would be 20 x (Vdd/5.5) = 20 x (3.3V / 5.5V) = 12ns .
1. Could it cause any problems(side effect) ?
2. How to increase the fall time to meet spec ?
訊息由此人編輯:ivan lee
Show LessHi,
I am trying to test a subjected project code with little modification(removed 3 channel MUX).
There is no changes in the output. Please help.
Attached project file for your reference.
Regards,
Ram
Show LessHi
This developer community site is a site where anyone can answer questions.
Is there a way to verify that the respondent is a Cypress's engineer?
Is the moderator icon to the right of the account name proof that you are a Cypress's engineer?
This is because I want to confirm that the questions and answers asked on this site are reliable in advancing development.
Hello,
I am considering error handling for I2C slave of PSoC4000S.
Please see the return value of SCB_I2CSlaveStatus() API.
[In case of write operation (master -> slave)]
1. Just program the error handling between /* your error handling here */ and /* your error handling end */.
if(0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_CMPLT))
{
if(0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_OVFL))
{
/* your error handling here */
/* your error handling end */
}
else if(0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_ERR))
{
/* your error handling here */
/* your error handling end */
}
/* your write operation handling here */
/* your write operation handling end*/
}
2. Just progarm the timeout handling between /* your timeout handling here */ and /* your timeout handling end */.
for example:
while(0 != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_BUSY))
{
/* your timeout handling here */
/* your timeout handling end */
}
[In case of read operation (master <- slave)]
3. Just program the error handling between /* your error handling here */ and /* your error handling end */.
if (0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_CMPLT))
{
if(0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_OVFL))
{
/* your error handling here */
/* your error handling end */
}
else if(0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_ERR))
{
/* your error handling here */
/* your error handling end */
}
/* read operation handling here*/
/* read operation handling end*/
}
4. Just progarm the timeout handling between /* your timeout handling here */ and /* your timeout handling end */.
for example:
while(0 != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_BUSY))
{
/* your timeout handling here */
/* your timeout handling end */
}
Is there anything else I can prepare?
Best regards,
Yocchi
Show LessHi,
I think I found a memory overwrite issue, and would like to confirm my understanding of what is going on.
I have found something out about the automatic DMA buffer, and I would like to confirm my understanding. I had tried IN_BUFFER[8] and OUT_BUFFER[8],
and my program wasn't working correctly. A counting variable kept getting overridden at approximately the ### location. I then changed to IN_BUFFER[32] and OUT_BUFFER[32].
With these new buffer lengths the issue was resolved. Please see https://www.cypress.com/file/376416/download pg 63.
"The DMA reading from or writing into the endpoint buffer happens in 32 byte chunks per request".
I contrast that with the code definition of ReadOutEp: "Valid values are between 0 and 1023", in which it speaks about the third parameter.
I think that I was overriding the other variables, because my buffer sizes were too small. Can I get a confirmation of this please?
#include "project.h"
#include <stdio.h>
#define IN_ENDPOINT 0x01
#define OUT_ENDPOINT 0x02
#define MAX_NUM_BYTES 1
#define PACKET_OK 1
#define PACKET_BAD 0
#define maxLength 19 // 20 long -> array element 19
// These are for the keypads
#define Pin_DM_STRONG (0x06u)
#define Pin_DM_RES_UP (0x02u)
uint8 IN_Data_Buffer[8] = {0};
uint8 OUT_Data_Buffer[8] = {0} ;
uint8 PacketNum = 0;
uint8 packetOk = 0;
char textIn[20];
char textOut[20];
uint8 textInLength = 0;
uint8 textInIndex = 0;
uint8 textOutLength = 0;
uint8 textOutIndex = 0;
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
// Start the Screen
LCD_Start();
Timer_Start();
keyTimer_Start();
LCD_ISR_StartEx(LCD_Interrupt);
keyISR_StartEx(Keypad_ISR);
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
USB_Start(0,USB_DWR_VDDD_OPERATION);
#define UnassignedAddress 0
while(USB_deviceAddress == UnassignedAddress)
{
// Wait for device address to be assigned
}
while(!(USB_GetConfiguration()));
for(;;)
{
uint8 interruptState;
interruptState = CyEnterCriticalSection();
/* Place your application code here. */
// the primary USB send and receive function
OUT_COUNT = 0;
// ensure that device is configured
//if(USB_bGetConfiguration() )
//{
if(USB_IsConfigurationChanged()) //make happen every time
{
//USB_GetInterfaceSetting(0); // works without this line???
USB_LoadEP(IN_ENDPOINT, IN_Data_Buffer, 8);
USB_ReadOutEP(OUT_ENDPOINT, OUT_Data_Buffer, OUT_COUNT);
USB_EnableOutEP(OUT_ENDPOINT);
}
//CyDelay(1);
//############################################################################################################
if ((USB_GetEPState(IN_ENDPOINT) == USB_IN_BUFFER_EMPTY ) ) //Data to send
{
USB_LoadEP(IN_ENDPOINT, NULL, 8);
//USB_EnableOutEP(OUT_ENDPOINT);
}
//CyDelay(1);
if(USB_GetEPState(OUT_ENDPOINT) == USB_OUT_BUFFER_FULL) /// Data to Receive
{
//############################################################################################################
OUT_COUNT = USB_GetEPCount(OUT_ENDPOINT);
USB_EnableOutEP(OUT_ENDPOINT);
}
//}
if (OUT_COUNT != 0)
{
char tempChar = (char)OUT_Data_Buffer[0];
// this loop resets the OUT line on LCD
// once it is full and more text has arrived
if(textOutLength > maxLength)
{
textOutLength = 0;
//LCD_Position(1u,0u);
// this loop blanks the OUT line on LCD
// it is 21 elements long, even though the screen is 20
// b/c I append a \0 when sending the text from PC
for(int z = 0; z <= 20; z++)
{
textOut
}
int bob = 0;
}
if (tempChar != 0)
{
textOut[textOutLength] = tempChar;
textOutLength = textOutLength + 1;
IN_Data_Buffer[0] = OUT_Data_Buffer[0];
if(textInLength > maxLength)
{
textInLength = 0;
textInIndex = 0; // should I update this one here???
for(int i = 0; i < 20; i++)
{
textIn = ' ';
}
}
textIn[textInLength] = IN_Data_Buffer[0];
textInLength = textInLength + 1;
}
}
CyExitCriticalSection(interruptState);
}
}
Show LessWe want to connect PSoC 4 and ESP8266. The module is working perfectly with Arduino and even Kitprog.
But it is not responding when we use 2 uart blocks to program the MCU. Please help with the circuit diagram and code.
Show LessHi,
On the CY8C4146FNI-S433T (PSoC 4 in 35-Ball WLCSP Package) there is a cover/coating. During the assembly process of our printed circuit assembly, this cover is sometimes damaged. This cover/coating appears to only contain the device markings such as pin 1 location and part number.
Does this coating serve any purpose other than identification? And if it is damaged during the assembly process, is it going to affect the performance of the device?
What is the best way to prevent damage to this coating? It seems quite sensitive to heat and pressure when the assembly is being thoroughly cleaned.
Thank you.
Show LessHello,
Please tell me how to enable both RX and TX polarity inversion and Wake up from Deep Sleep mode from UART.
If I set it as shown below, a warning will occur.
Is it needed if I output TX and RX from the terminal once, return it to SmartIO, invert it, and output it again?
Best regards,
Yocchi
Show Less