PSoC™ 5, 3 & 1 Forum Discussions
Hi,
I’ve been working on I2C communication between a PSOC 5LP (master) and multiple PSOC 4’s (slaves). This is being done with a Cy8CKIT-059 and multiple Cy8CKIT-049-42xx boards. The goal is to be able to add a slave device to the bus, in a default configuration with address 0x08, and have the master assign it a new address and maintain a list of all currently used slave addresses. The slave stores its address in flash (Emulated EEPROM) so at power up the configuration remains unchanged. For now, the part about having the master store a list of addresses has been set aside and I’m just sending commands through USBUART via a terminal.
Most of this project is functioning correctly, but I’m running into a few hiccups that really come down to error checking. There are also some parts of the code that aren’t exactly elegant, but thus far my goal has been to just get things working, so please excuse them. I have attached a zip with the main.c and main.h for both the master and slave. My questions are:
1. I am using the I2CMasterWriteBuf and I2CMasterReadBuf API functions and they are working well. My problem is that these API functions are returning “SCB_I2C_MSTR_NO_ERROR” when they try to talk to a slave address that does not exist. I am clearly not understanding how the return value of the functions is created and would like to be able to find out if a slave is not on the bus and generate an error.
2. The second concern is regarding sending a save device a command to change its address. I am currently using a simple block check to validate packets, which is working as expected. I would like to find a way to generate some kind of acknowledgement from a slave saying that the incoming packet is valid before executing its address change. This way the master knows the packet was received correctly and can update its slave address array accordingly.
As of now if the block check isn’t correct the slave will not attempt to update its address, but the master has no way of knowing that this did not happen. The only way I can do this right now is to attempt to read from the new slave address and see if the correct status value is returned, indicating a successful address change, though if the address isn’t there I run into the previous problem. This can be worked around by checking that the status in the returned packet is correct, but it feels a bit like going around my elbow to get to my rear and, frankly, I don’t really like it.
I’m currently using the MasterWriteBuf and MasterReadBuf functions with the mode set to “MODE_COMPLETE_XFER” which I have a hunch is part of the problem. I feel like I need to use the “MODE_NO_STOP” mode, but I don’t understand how this works and can’t seem to get things working with it.
I’m new to Cypress devices as well as I2C. Any help with understanding where my logic is incorrect or guidance to a solution would be greatly appreciated. If anything isn’t clear I’ll be happy to try and resolve any ambiguity.
Thanks,
Matthew
Show LessDear Cypress Developer Community,
I got inspired by the hackster.io project "PSoC 4 : (4+3=) 7$ Auto Ranging Ohms Meter" (https://www.hackster.io/PSoC_Rocks/psoc-4-4-3-7-auto-ranging-ohms-meter-41dc9e).
Because I do not have a PSoC 4 available, I ported the project to PSoC5LP (CY8CKIT-059). By testing the code, I noticed that the ohms meter is working fine for lower unknown resistance values (Rx less than few hundred ohms), but auto ranging ohms meter is showing significant errors for higher resistances.
Step-by-step I changed the hackster.io code to try to identify the error. Attached you can find my latest PSoC Creator version. For simplicity, only 4 predefined measurement-currents are taken: 2mA, 0,2mA, 20uA, 2uA. In the first attempt, IDAC is set to 2mA. If the measured ADC-voltage is above 1V, the next current range is taken (0.2mA), and so on...
As soon as measured voltage is below 1V, the resistance value is calculated by R = U/I.
For debugging purposes, the i-range is printed out at the character LCD-display as well.
Here are some measurement results:
Rx-value resistance measured by PSoC range
100Ohm 98 Ohm 0
1,5kOhm 1482 Ohm 1
47kOhm 50 kOhm 2
100kOhm 279 kOhm 3
Interestingly, if I put a break point at code line 63 (adc_result = ADC_GetResult16();) and press continuously F5 (Resume Execution) in debug mode, I get much better measurement results:
Rx-value measured in debug mode range
100Ohm 99 Ohm (99.14 Ohm) 0
1,5kOhm 1487 Ohm (1487.79 Ohm) 1
47kOhm 46 kOhm (46.410 Ohm) 2
100kOhm 103 kOhm (103.947 Ohm) 3
I figured out that I need to add a CyDelay between
ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);
and
adc_result = ADC_GetResult16();
to get closer voltages. If the delay is 200ms, I still see significant errors with 100k testing resistor (measured: 133k). By setting delay to 1s, everything seems fine... but ohms meter is acting quite slow... and furthermore, I do not understand why a CyDelay is needed here at all ?!?!
I'm open for any ideas... because currently I have no clue what's going wrong here...
Thanks,
Michael
Does anyone have a working example for PSoC5 of a USB composite device with MIDI and USBUART (CDC)? Got each one of them working separately but I can't figure out how to do both.
Show LessI am using the 1msps SAR to get around 8 samples per waveform of an echoed 120khz signal. (used in material examination). It is working ok.
Unfortunately the internal DAC can only do 8 bits, so when playing the 12 bit signal back at a slower rate using the 8 bit DAC, to be used in other equipment, the loss of resolution is affecting the waveform amplitude between echo samples, as you would expect.
One possibility would be to interpolate data to play out the DAC and derive more samples. If the sample rate is computationally doubled, this would provide a stable enough signal. I am trying to wrap my mind around that one, and have not seen any C examples. I think I can do it, but I'm still a bit confused about getting the missing Y value for an X from the formulas I've seen. My brain is missing something in addition to gray matter.
The other way to do it would be to offset using 2 SAR's exactly 1/2 so that one gets one sample and 500us later the other SAR would get the other sample. I could interleave the samples and shift out the DAC. So, it leads to the following questions:
1) Any C code for interpolation I could be pointed to that is geared for getting missing DAC samples. (Linear interpolation is obvious, cosine, maybe, Levinson-Devinson sounds good)
2) Any examples of shifting the SAR's so they are offset from each other exactly half? Any luck doing the DMA in that configuration? I have DMA running, but I've found that the PSoc sometimes lays down like a sick puppy if the DMA's are too busy.
Show LessHi,
I am working on power line communication on CY3274 development board , and wanted to use i2c protocol to communicate with the I/O expander but unable to implement it.The problem is the chip(i.e CY8CPLC20) is unable to generate clock on SCL pin(i.e P1[7]).
Can anyone help me to solve this problem
Regards
Shafi
Show LessI'm attempting to use the emWin function GUI_BMP_DrawEx() to draw a .bmp image stored in external Flash onto a window. I've also implemented a getData() function as shown in the examples.
If I try to draw an image onto the background window using GUI_BMP_DrawEx() everything works as expected. The getData function gets accessed several times and the image is correctly displayed.
However, if I try to call the same function from within the WM_PAINT case in a window's callback function, it will go in the getData() function and read the first 54 bytes as expected, but when it goes back in to getData() the second time the Offset is not 54 but rather some random value. The program then continues to use the getData() function to read from flash but the offset value is always different and random. It never returns from GUI_BMP_DrawEx().
Strangely, if I call GUI_BMP_DrawEx() from the WM_INIT case, the function will call getData() once and then return immediately. In either case the images do not get displayed.
I don't understand this behavior. Any help would be greatly appreciated.
Thank you,
Show LessI am transferring multiple analog voltage measurements through optic fibers, thus i convert the analog signal in to variable frequency (square wave pulses through V/f converter). On the receiver end i want to avoid the hardware f/V conversion and i would like to achieve this through PSOC, as i want to process these measurements without the need of the ADC.
Any suggestion is much appreciated!
/Dimz
Show LessHi,
I have a project using PSoC 5 and would like to know how much stack memory is being used. Does anyone aware of utility function for this purpose?
I am now assigning 8k for the stack and think it should be enought but would like to know what percentage it acutally is being used. Don't want to have a stack overflow problem after releasing the product.
I have do the same checking for a PSoC 1 project by filling the stack RAM with 0x55 and check the stack RAM after runing to project for a few days and try to perform all the function of the product. I know it is not 100% as it may not exercise the wrost combination but it would give at least a better value than just guesting.
Any one has experience with GCC ARM compiler to show me how it can be done? or utility functions that can be used?
Thanks
Lawrence
Show LessIs the PSoC5LP dev board capable of running the components necessary to develop a TCPWM interface as in this datasheet?
This is my first run at a PSoC solution, i'm coming from embedded linux background and PIC stuff..
Want to make sure im headed in the right direction.
Chris
Show LessHi everyone
I'm trying to get working a project which transfer data from SRAM Buffera[166] to DFB and DFB to SRAM Bufferb[166] using two DMA components.
I would need some help to set the above mentioned buffers at address 0x20000000 and 0x2000014E.
Using int16 myVar[166] _at_ 0x20000000 produce compiler error.
Thank you very much for any help.
Show Less