PSoC™ 5, 3 & 1 Forum Discussions
text.format{('custom.tabs.no.results')}
I need a voltage 3.5V from cy8c3866.I use DA generated 3.5V, and with a follower to output the voltage. Output voltage is 3.5V when no any load,and voltage will down to 2.7V when drive a resistance 1.8K. The problem is, why follower cann't drive a 1.8K resistance?How much the max current and internal resistance of follower? Thank you.
Show Less
Hi all,
I'm using the I2C on a CY8C5267LTI-LP089 chip and I've implemented a solution that talks to a slave that manages a battery in my device.
My code is below.
The short story of it is that I write a single command byte, read the return date (either 2 or 4 bytes), then store that data to be sent out on USB, then repeat for the next command byte.
void Internal_BAT_I2C(void) //This function is called in the main loop amongst other things
{
static uint8 Internal_Gas_Gauge_Address[40] = {0x00,0x08,0x09,0x0A,0x0D,0x0E,0x11,0x12,0x13,0x16,0x17,0x4F,0x01,0x02,0x03,0x0B,0x0C,0x0F,0x10,0x1B,0x3C,0x3D,0x3E,0x3F,0x14,0x15,0x18,0x19,0x1A,0x1C,0x60,0x61,0x62,0x55,0x56,0x50,0x51,0x52,0x53,0x54};
static uint8 Internal_I2C_Command[1]; // i2C write pointer
static uint8 Internal_BAT_I2C_Step = 1 ; //internal bat i2c step
static uint8 I2C_Internal_BAT_CMD_SEQ = 0; //used for incrementing the I2C address
static uint8 Internal_BAT_I2C_READ_BYTE_COUNT;
static uint8 Internal_BAT_I2C_WRITE_BYTE_COUNT;
static uint8 Internal_I2C_buffer[5]; //I2c read buffer pointer
if (Internal_BAT_I2C_Step == 1) // I split the I2C transaction into steps so that other parts of the firmware can run while it resolves.
{
I2C_INTERNAL_BAT_MasterClearStatus();
Internal_BAT_I2C_WRITE_BYTE_COUNT = 1; // Write single byte to I2C -command byte of gas gauge
Internal_I2C_Command[0]= Internal_Gas_Gauge_Address[I2C_Internal_BAT_CMD_SEQ]; // = 0x20;
I2C_INTERNAL_BAT_MasterWriteBuf(0x0B, (uint8*)Internal_I2C_Command, Internal_BAT_I2C_WRITE_BYTE_COUNT, I2C_INTERNAL_BAT_MODE_NO_STOP);
Internal_BAT_I2C_Step = 2; //Write is done so proceed to read step on next loop
}
// If the write is finished then
if (((I2C_INTERNAL_BAT_MasterStatus() & I2C_INTERNAL_BAT_MSTAT_WR_CMPLT)!=0u) && (Internal_BAT_I2C_Step == 2) && ((I2C_INTERNAL_BAT_MasterStatus() & I2C_INTERNAL_BAT_MSTAT_ERR_XFER) != 0u))
{
I2C_INTERNAL_BAT_MasterClearStatus();
if (Internal_I2C_Command[0] == 0x50 || (Internal_I2C_Command[0] == 0x51) ||(Internal_I2C_Command[0] == 0x52) ||(Internal_I2C_Command[0] == 0x53) || (Internal_I2C_C
ommand[0] == 0x54) ||(Internal_I2C_Command[0] == 0x60) || (Internal_I2C_Command[0] == 0x61) ||(Internal_I2C_Command[0] == 0x62) ||(Internal_I2C_Command[0] == 0x55) || (Internal_I2C_Command[0] == 0x56) ) {
Internal_BAT_I2C_READ_BYTE_COUNT = 5;
}
else
{
Internal_BAT_I2C_READ_BYTE_COUNT = 2;
}
I2C_INTERNAL_BAT_MasterReadBuf(0x0B, (uint8*)Internal_I2C_buffer, Internal_BAT_I2C_READ_BYTE_COUNT, (I2C_INTERNAL_BAT_MODE_COMPLETE_XFER|I2C_INTERNAL_BAT_MODE_REPEAT_START));
Internal_BAT_I2C_Step = 3;
}
// if the read is finished then store data to be sent to USB
if (((I2C_INTERNAL_BAT_MasterStatus() & I2C_INTERNAL_BAT_MSTAT_RD_CMPLT)!=0u) && (Internal_BAT_I2C_Step == 3) && ((I2C_INTERNAL_BAT_MasterStatus() & I2C_INTERNAL_BAT_MSTAT_ERR_XFER) != 0u) )
{
if (Internal_BAT_I2C_READ_BYTE_COUNT == 2)
{
Internal_Gas_Gauge_Data_B0[I2C_Internal_BAT_CMD_SEQ]=Internal_I2C_buffer[0];
Internal_Gas_Gauge_Data_B1[I2C_Internal_BAT_CMD_SEQ]=Internal_I2C_buffer[1];
}
if (Internal_BAT_I2C_READ_BYTE_COUNT == 5)
{
Internal_Gas_Gauge_Data_B0[I2C_Internal_BAT_CMD_SEQ]=Internal_I2C_buffer[1];
Internal_Gas_Gauge_Data_B1[I2C_Internal_BAT_CMD_SEQ]=Internal_I2C_buffer[2];
Internal_Gas_Gauge_Data_B2[I2C_Internal_BAT_CMD_SEQ]= Internal_I2C_buffer[3];
Internal_Gas_Gauge_Data_B3[I2C_Internal_BAT_CMD_SEQ]= Internal_I2C_buffer[4];
}
//This section of code selects the next command byte to be sent. We just iterate through the entire list
Counter_1_Start(); //using counter to add 20msec delay between each commands - start the counter
if (Counter_1_ReadCounter() <= 59980) //wait for 20msec or more (Scope measured ~80ms delay with USB connection and ~40ms with no USB connection)
{
Counter_1_Stop(); //stop the counter
Counter_1_WriteCounter(60000); //reset the counter back to its orginal
if (I2C_Internal_BAT_CMD_SEQ == 39)//if we've reached the last command then reset to the first
{
Counter_2_Start();
if (Counter_2_ReadCounter() <= 59000) //wait for at least 2sec before reading the same command again
{
Counter_2_Stop(); //stop the counter
Counter_2_WriteCounter(60000);
I2C_Internal_BAT_CMD_SEQ = 0;
Internal_BAT_I2C_Step = 1;
}
}
else
{
++I2C_Internal_BAT_CMD_SEQ;
Internal_BAT_I2C_Step = 1;
}
}
}
}
The problem I'm running into is that despite giving I2C_MasterWriteBuf() only a single byte it will randomly send an extra 2 bytes. My I2C bus locks up and won't recover until the the system is power cycled. At the same time the I2C bus locks up I've noticed that the USB sending data to Windows from Cypress also disappears and shows as an unknown device in Device Manager so I think the chip itself may also be locking up.
Here's a capture of the failure with my I2C sniffer.
Can someone comment on this? I can't see a reason why my code would cause or allow extra bytes to be sent. I also can't explain the relation between the USB failing in conjunction with the I2C.
Cheers
Kevin
Show Lesshello I am currently using FreeSoC2 Development Board - PSoC5LP my question is simple .
Psoc is it FPGA or ASIC or both ? I am a bit confused
Show LessHi All,
I'm using the I2C master (Fixed Function, V3.5) and trying to communicate with a DS1307 Real Time Clock.
When I put the SCL and SDA lines on a scope / digital analyser it is showing the address as 0x50 instead of 0xD0 needed for the RTC. (It looks like it is dropping the first bit of the write command.
I'm using the CY8CKIT-059 PSoC 5LP prototyping kit. (Using 12_0 for SCL and 12_1 for SDA.)
My code is basically:
#define I2C_SLAVE_ADDR (0xd0u)
/* Delay between commands in milliseconds */
#define CMD_TO_CMD_DELAY (500u)
void main(void)
{
I2C_Start();
CyGlobalIntEnable;
for(;;)
{
ReadStatusPacket();
CyDelay(CMD_TO_CMD_DELAY); /* Delay between commands */
}
}
uint32 WriteCommandPacket(uint8 cmd)
{
uint8 buffer[BUFFER_SIZE];
uint32 status = TRANSFER_ERROR;
buffer[0] = cmd;
(void) I2C_MasterWriteBuf(I2C_SLAVE_ADDR, buffer, 1, I2C_MODE_COMPLETE_XFER);
/* Waits until master completes write transfer */
while (0u == (I2C_MasterStatus() & I2C_MSTAT_WR_CMPLT))
{
}
/* Displays transfer status */
if (0u == (I2C_MSTAT_ERR_XFER & I2C_MasterStatus()))
{
/* Check if all bytes was written */
if (I2C_MasterGetWriteBufSize() == 1)
{
status = TRANSFER_CMPLT;
}
}
else
{
status = TRANSFER_ERROR;
}
(void) I2C_MasterClearStatus();
return (status);
}
uint32 ReadStatusPacket(void)
{
uint8 buffer[BUFFER_SIZE];
uint8 my_cmd[2];
uint8 datacount =0;
uint32 status = TRANSFER_ERROR;
my_cmd[0] = 0xd0;
my_cmd[1] = 0xff;
(void) I2C_MasterWriteBuf(I2C_SLAVE_ADDR, my_cmd, 1, I2C_MODE_COMPLETE_XFER); // should set address/reg to read.
// Waits until master completes write transfer
while (0u == (I2C_MasterStatus() & I2C_MSTAT_WR_CMPLT))
{
}
// Displays transfer status
if (0u == (I2C_MSTAT_ERR_XFER & I2C_MasterStatus()))
{
// Check if all bytes was written
datacount = I2C_MasterGetWriteBufSize(); // how many bytes went out?
}
else
{
status = -1; // there was an error
}
(void) I2C_MasterReadBuf(I2C_SLAVE_ADDR, buffer, 6, I2C_MODE_COMPLETE_XFER );
/* Waits until master complete read transfer */
while (0u == (I2C_MasterStatus() & I2C_MSTAT_RD_CMPLT))
{
}
/* Displays transfer status */
if (0u == (I2C_MSTAT_ERR_XFER & I2C_MasterStatus()))
{
status = TRANSFER_CMPLT;
}
else
{
status = TRANSFER_ERROR;
}
(void) I2C_MasterClearStatus();
return (status);
}
=======================================================
thanks for any suggestions,
Bob
below is what I'm seeing on the scope.
Show Less
I am using PSOC-5 with the 059 Kit with PSOC creator 4.2 and trying to interface it with a SD card via the emFile application. I have linked all the libraries as per the emFile datasheet and copied the code from the example (removed the LCD part). However, I get the following errors:-
Build error: device.h: No such file or directory
Build error: The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.
The workspace and project bundle are attached with this post.
I read on the forum that the arm_gcc.exe issue can be caused by a faulty installation so I uninstalled PSOC creator - restarted PC - then downloaded the file from the website and installed it again and restarted the PC again. Nothing changed.
Please let me know what I am doing wrong and how to fix it.
Note:- the workspace is the Blinking LED file (as I modified the Blinking LED example project) and the Project is the FATFS file.
Thanks in Advance,
Sujoy.
Show LessHello everyone,
I'm creating this topic because I'm having some difficulties on interfacing PSoC with Matlab. I've watched this tutorial (Graficar Datos De PSoC 4 En MATLAB - YouTube ) and the project compiles, but when run the Matlab side, it gives me an error that seems to say that nothing is passed from the UART to Matlab.
What I do is generate a wave with the WaveDAC component, which is the one that the ADC detects and then I want to be able to see the ADC output on Matlab (using the UART component).
Attached to this post are the PSoC project and the MATLAB script
Show Lesshello I want for my project to send from my board to out pin a serios of bits 1 or 0 meaning the i will get
and again i dont want to use wavedac i want to send signals of 1 or 0 manually
Show LessHi, I am using the psoc 5. I am trying to make an interrupt as soon as the voltage on one of my digital input pin gets to 0 or close to it (set to be Resisitive pull up). The problem is that I want the interrupt as soon as the voltage gets to 0.4V or lower and the interrupt is only initiated if the voltage on the pin is hard 0.
How can I solve this problem.
Thanks a lot for all the help
Show LessHi every body.I am using psoc5 lp prototype kit.I want to run camera with psoc5 and take a picture then save on sdcard.Could you help me to do it?
How can i run camera with usb interfacing with psoc5 usb port?is it possible?
please give me a sample code or any project to do it faster.
thank you for attention...
Show LessHi,
does anyone know a tool which generates an inf file automatically? The USB component customizer seems to generate a standard inf file for e.g. CDC implementation (which points to the Microsoft CDC driver, not the Cypress driver), but if an vendor specific interface is implemented, it seems that the inf file must be created manually. Any ideas?
Regards
Show Less