PSoC™ 5, 3 & 1 Forum Discussions
Hello,
I'm having some problems getting my 64-Byte HID interface working properly, and I'm stumped as to why. I mostly used this as a reference: https://www.cypress.com/file/134411/download
https://www.cypress.com/file/134411/download
My code to process the endpoints, based on the code in Appendix A of AN82072 is as follows:
static uint8_t USB_InBuffer[64];
static uint8_t USB_OutBuffer[64];
#define CONFIG_STX 0x02
void Process_USB(void){
/*IN Buffer is data going INTO PC*/
if (USBFS_bGetEPState(1) == USBFS_IN_BUFFER_EMPTY){
USBFS_LoadInEP(1, USB_InBuffer, 64);
memset(USB_InBuffer, 0x00,64);
USBFS_EnableOutEP(2);
}
/*OUT Buffer is data coming OUT OF PC*/
if (USBFS_bGetEPState(2) == USBFS_OUT_BUFFER_FULL){
USBFS_ReadOutEP(2,USB_OutBuffer,64);
if (USB_OutBuffer[0] == CONFIG_STX){
UART_PutString("RCVD\r\n");
/*Process Data Here*/
}
memset(USB_OutBuffer,0x00,64);
USBFS_EnableOutEP(2);
}
}
I've been able to determine that using EP1 (IN) works fine as far as I can tell. I drop my bytes into the USB_InBuffer and they show up on the host no problem. What is giving me fits is EP2 (OUT). What I'm seeing that that when I send a data to the PSoC from the host PC, I hit USBFS_ReadOutEP() just as I should, and when I put a breakpoint on USBFS_ReadOutEP() I notice that the USB_OutBuffer seems to already contain the data packet I sent via my .NET application:
Data at Beakpoint:
Then, if I break on the next line (checking for my 0x02 STX byte) my contents of USB_OutBuffer are now completely different!
This leaves me with 2 questions:
1) Why does my USB_OutBuffer contain the data I sent before I've read the OUT endpoint
2) Why does reading the OUT endpoint overwrite USB_OutBuffer with (seemingly nonsensical) data?
I've been banging my head against the desk all morning, I can't figure out why this is occurring!
I've also attached the project, I'm running this on a CY8CKIT-050. There's a bunch of other code in there related to RS232 and an attached keypad that shouldn't matter (I've commented out the calls for processing RS232 and Keypad in main). If anyone could take a look and let me know if I'm missing (or misunderstanding) something it would be greatly appreciated!
Show LessHello all,
I am trying to program my psoc 3 device through SWD protocol but getting error.
With the help of 10 pins ,JTAG programming is working fine but with the same setup getting the below error.
Please help me out.
Thank you,
Saurav
Show Less
We have a PSoC 5LP powered board, and are having trouble where errors on the I2C communication cause the I2C master component to "lockup" in a way that the only recovery I can find is to reset the board.
Here's the setup: The fixed function I2C is wired to internal Muxs, that connect it to one of eight external I2C buses. Reads from the I2C bus take the following form (this one writes a byte, then reads two bytes...):
uint8 i2c_1_Register_RD_No_MUTEX (uint8 reg_address, uint16 * value) {
uint8 ret;
if (value == NULL) return I2C_COMM_PARAM_ERROR;
i2c_1_Bus_Select(A_BUS_ADDR);
I2C_1_MasterClearStatus();
vTaskSuspendAll();
if ((ret = I2C_1_MasterWriteBuf(I2C_ADDRESS, ®_address, 1, I2C_1_MODE_COMPLETE_XFER)) == I2C_1_MSTR_NO_ERROR){
timeout_count = 0;
do {
CyDelayUs(80u);
timeout_count++;
} while ((I2C_1_MasterStatus() & I2C_1_MSTAT_XFER_INP) == I2C_1_MSTAT_XFER_INP && timeout_count < TIMEOUT);
if (timeout_count >= TIMEOUT){
ret = I2C_COMM_BUS_TIMEOUT;
}
else{
ret = I2C_1_MasterReadBuf(I2C_ADDRESS, buffer, 2, I2C_1_MODE_COMPLETE_XFER);
timeout_count = 0;
do {
CyDelayUs(80u);
timeout_count++;
} while ((I2C_1_MasterStatus() & I2C_1_MSTAT_XFER_INP) == I2C_1_MSTAT_XFER_INP && timeout_count < TIMEOUT);
if (timeout_count >= TIMEOUT){
ret = I2C_COMM_BUS_TIMEOUT;
}
}
}
xTaskResumeAll();
if (ret != I2C_1_MSTR_NO_ERROR){
bus_reset();
logSpecial("%d error from i2c bus in i2c_1_Register_RD_No_MUTEX", ret);
return(I2C_COMM_ERROR);
}
*value = (buffer[0] << 😎 + buffer[1];
return i2c_CheckStatus();
}
i2c_1_Bus_Select takes an address identifier to hand to the mux control register. It's sets the pins for that bus open-driain, drives low. It sets the other pins on all other buses High Impedance Digital.
If there's an error, bus_reset() shuts down the FreeRTOS scheduler, disabled interrupts, sets all buses to High Impedance Digital, calls I2C_1_Stop(), then I2C_1_Init(), then I2C_Start(). Then it turns interrupts and the scheduler back on.
i2c_CheckStatus() simply checks the status, and returns the error (and logs it) unless the status is No_error or read/write complete.
Most of the time, this setup will handle the odd transient error from I2C devices without issue. But occasionally, most notably with timeout errors, the I2C component will refuse to communicate, no matter what bus it's hooked to, or how many times the bus_reset() function is called. It will always report "Bus Busy." The only way out of that situation is to perform a full reset of MPU.
I am looking into switching the I2C Master component from the fixed-function version to the UDB version, but it'll be a test only because we'll need to remove functionality from the system to make room for it. The idea is getting access to the Reset pin, and seeing if hitting that will allow the system to recover without restart the software.
Is there something I'm missing, or is this just the nature of the beast. We're working to minimize the errors over the I2C bus, but one of the more troublesome applications is a PMBus based power supply. When it's running at full power, it seems to get touchy.
Show Lesshow CY7C63813 enable USB_EP2_ISR,
My USB device is HID,use Endpoint 1 to IN and Endpoint 2 to Out, bmAttributes is 3(USB_ENDPOINT_TYPE_INTERRUPT)
but when PC send data to cy7c,it can not triger USB_EP2_ISR. thank you for hlep.
export USB_EP2_ISR
export _USB_EP2_ISR
USB_EP2_ISR:
_USB_EP2_ISR:
;@PSoC_UserCode_BODY_EP2@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom code below this banner
;---------------------------------------------------
; NOTE: interrupt service routines must preserve
; the values of the A and X CPU registers.
STD_EP2: EQU 1 ; Set this equate to 0 to remove the standard
; endpoint handling code
;---------------------------------------------------
; Insert your custom code above this banner
;---------------------------------------------------
;@PSoC_UserCode_END@ (Do not change this line.)
IF STD_EP2
PUSH A
XOR [USB_EPDataToggle], 4 ; Update EP2 data toggle
MOV A, REG[EP2MODE] ; Get the mode
MOV [USB_EndpointAPIStatus + 2], EVENT_PENDING ; For the API
POP A
RETI
Show LessI need to change SPI bus width in between 16 and 8 for different slave where can I do it is any smaple code that you can share
Regards
Albert
Message was edited by: Alberto Tello in the picture three bytes are written 0x80, 0x03, and 0x00 Why I have those glitches in MSB byte
Show LessHello.
I am trying to create a program using the Psoc 5lp board. The exact board I am using is the CY8C5888LTI-LP097. I have been trying numerous examples of digital filtering. The first attempt I tried reading in an uint16 value from an ADC, sending that reading through a digital filtering equation that I derived myself. Next, I scaled that filtered 16 bit value to a uint8 value and used a WaveformDac to output the signal. This approach did not work as planned. After this I have tried the numerous examples using ADC to DMA to FILTER to VDAC and have failed each time.
If anybody has any suggestions I would appreciate hearing them. One thought is that this exact board is not capable of doing this.
Any thoughts or suggestions are appreciated.
-Cory
Show LessHi all,
I am currently working on an RC car for which my wireless communication module is an H-05. The kit I am using is the CY8CKIT-059. I have never used them before but so far I have managed to pair them. I am currently trying to try something simple to test like driving an LED on the other board. So far I have been unsuccessful. I do not know how to attach a project so I will attach the code and some pictures which should be enough.
Transmitter:
/* ========================================
*
* Copyright YOUR COMPANY, THE YEAR
* All Rights Reserved
* UNPUBLISHED, LICENSED SOFTWARE.
*
* CONFIDENTIAL AND PROPRIETARY INFORMATION
* WHICH IS THE PROPERTY OF your company.
*
* ========================================
*/
#include "project.h"
int Rx;
char str;
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_1_Start();
for(;;)
{
if(BTN_Read()==0){
UART_1_PutChar(100);
Pin_1_Write(1);
}
else{
UART_1_PutChar(100);
Pin_1_Write(0);
}
}
}
/* [] END OF FILE */
Receiver:
/* ========================================
*
* Copyright YOUR COMPANY, THE YEAR
* All Rights Reserved
* UNPUBLISHED, LICENSED SOFTWARE.
*
* CONFIDENTIAL AND PROPRIETARY INFORMATION
* WHICH IS THE PROPERTY OF your company.
*
* ========================================
*/
#include "project.h"
uint8_t Rx;
char str [120];
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_1_Start();
for(;;)
{
Rx = UART_1_GetChar();
UART_1_PutChar(Rx);
}
}
/* [] END OF FILE */
Any help is appreciated.
Thanks
Show LessHi
I have an issue on PSOC 5LP device.
There are 2 projects where I use a HEX rotary switch.
I do not use external pullup but rely on the digital pin onboard pull up resistors.
One project has the Switch connected to port pins P0.7 through to P0.4 and works fine. (and has worked fine like this for a couple of years I have built that project)
The other project has switch connected to pins P5.6 through P5.4 and LSB on P12.7 and I cannot read the switch properly. I only every get "1" or "0" from various switch settings. It appears P12.7 LSB works but no reading from the upper 3 bits on P5.
I checked Vio pins an they have 3.3V ok. The continuity between pins and switch are correct and there is no short. The switch is grounded correctly. If I remove power and measure continuity on switch as I change values, I get correct values.
This occurs on all the boards I build so I am confident it is not an assembly issue.
Is there something on port P5 when used as digital input that is different from P0? I am not sure what else to try.
Thanks
Show LessDear All:
I'm in the process of creating a "pressure monitor" using PSoC 5 LP-059.
Currently there is a problem.
When the power is turned on, the display of 7SEGMENT will drift.
It will converge after about 5 minutes.
The hardware solution was to insert an LPF into the AD input of PSoC 5 LP-059.
It is a combination of 10KΩ and 4.7μF.
Please advise if there is a good way to prevent this drift of the amplifier.
Software measures are also welcome.
Show LessHello, I have an application in which another processor is the Master SPI and the PSOC5 is the Slave SPI. The SPI clock is 800Khz and I would like the Master to send over 10 bytes in a burst. The Master is receiving 10-bytes back from the SPI Slave which is good. The problem is the SPI slave is not receiving all 10 bytes and the sequence is not correct.
Originally I did not use a DMA to receive the data but the Slave was dropping bytes. So, I thought I should try using a DMA. I am fortunate to have found an example using a DMA to read the SPI Rx FIFO.
I got the example to work but now the problem is I only receive 4 bytes of data. The SPI interrupt is set which kicks of a DMA transfer. I see the interrupt occurring 10 times which is good but the data is missing:
I don't know what I must do to capture all of the 10-bytes form the Master SPI device.
I would like to be able to send a burst of data rather than sending a byte and then delay and then send another byte.
If anyone can help me with getting this to work or suggest another approach that does not require a DMA please let me know.
Thanks,
Joe
Show Less