PSoC™ Creator & Designer Forum Discussions
I couldn't make ftoa work and I wanted to control the display format and rounding - then I came across this code snippet and adapted it but it's still not quite what I need.
Can someone please help me tweak it to add a significant digit parameter so that I can specify how many digits after the decimal point?
Here is the routine
//*****************************************************************************
// TM convert float to string
// tested and working on PSoC6
//*****************************************************************************
void tmFtoStr(char* p, float x)
{
int n,i=0,k=0;
n=(int)x;
while(n>0)
{
x/=10;
n=(int)x;
i++;
}
*(p+i) = '.';
x *= 10;
n = (int)x;
x = x-n;
while((n>0)||(i>k))
{
if(k == i)
k++;
*(p+k)='0'+n;
x *= 10;
n = (int)x;
x = x-n;
k++;
}
/* Null-terminated string */
*(p+k) = '\0';
}
I call it like this
int main(void)
{
float flt1;
char myString[20]={};
flt1 = 3.142;
tmFtoStr(myString, flt1);
printf("%s\n", myString);
.......
}
but the print out from the above is like this...
3.141999721527
I think I know what to do but I am scared that I'll break it - I want to add a sigDig parameter so I call it like this...
tmFtoStr(myString, flt1, 3);
and get 3.142 - ideally doing rounding if possible. Any help would be appreciated.
Also, is the problem above because of the inability of floats to store precisely?
Ted
Show LessHi Guys,
I am trying to build binary for CYBL10563-56LQX1 processor with came with came with CY8CKIT-042-BLE PIONEER KIT.
I managed to generate the a make file from the PSoC Creator and use it to build the application under Ubuntu Linux.
But the hex file created by the objcopy does not work. I mean the PSoC Programmer does not load.
The command I used to generate the hex file is as follows:
arm-none-eabi-objcopy -j .text -j .data -O ihex "$1" output/debug/bin.hex
I have compared the binary produced by objcopy and cyelftool.exe with a hex editor and found that the format is completely different.
Clearly the linux command is not doing the job.
Anyone knows how I can generate the correct hex file for the KIT? Or may be load the objcopy hex file?
Your help will be much appreciated.
Thanks in advance.
Show LessHello!
I'm trying to use project CapSense_Tuner_EZI2C02 on my CY8CKIT-062-BLE to tune the board's proximity sensor.
I've tried the following
- Add the proximity sensor to the project on CapSense's configuration on TopDesign.cysch;
- Set proximity sensor pin to P8.0;
- Build the project;
- Flash the board;
- Start CapSense Tuner by right clicking CapSense on TopDesign.cysch, and then clicking "Launch Tuner";
- On CapSense Tuner, configure I2C as following:
- I2C address: 8;
- Sub-address: 2-Bytes;
- 3.3 Volts;
- ON;
- I2C Speed: 400kHz.
- Hit "Connect".
However, I get the following error message: "Checksum mismatch for the data stored in the device and the data loaded to the Tuner (expected: 0xC3C2, obtained: 0xA7DC). Make sure the chip is programmed with the correct hex file and communication channel configuration is correct."
It is important to note that everything works perfectly when I don't change anything (proximity sensor not added).
Show LessI am trying to debug my project, which uses Bootloadable/Bootloader. This has been working fine for about a year.
When Bootloadable is disabled, I can program the chip and then "Attach to running target" with no problems, so I don't think this is a hardware problem.
When I enable Bootloadable, program, and then try "Attach to running target", no targets are displayed.
"Enable Device Protection" is disabled in the application code and the bootloader.
Any ideas about what could have changed?
Thanks.
Show LessUsing PSoc4 224110, seeing some issues with I2C Errors and looking to recover the bus. I'm seeing conflicting responses and wondering what the recommended method is.
Two Issues:
1. A slave device is in mid-transaction and holding the bus down. Typically the response is to manually toggle SCL until it releases the bus.
2. Of course when this happens the I2C Master is also busy and that must be reset as well. Is it sufficient to just I2C_Stop() and I2C_Start()?
Read all of the following without finding a good answer:
Trouble resetting I2C Master after glitches.
I2C Master stuck - MCSR stuck with START_GEN set
CYW20719 and CYW20735 I2C Compatible Master
Show LessWell, during a debug session, current practice is to print source code pages including the code line number.
Psoc Creator display the code line number on screen but do not print it!
Is there an option to force the line number printing?
If not is there a way to replace the Actipro Software SyntaxEditor by a third party source code editor?
Strange...
Show LessI have a project where I enable various components in the schematic. I detect that in my code to do conditional compilation, but I would like a reminder note to show in the Notice List in Creator. I am able to get it to the warning list using "#pragma GCC warning 'message'", but company policy requires no "Warnings in compiles", so I would like it to show in the Note category in the Notice window instead. How is that done?
Show LessThis forum contains a number of discussions about using the PSoC I2C SCB to implement an SMBus MASTER interface, Unfortunately, I have seen several suggestions, but no definitive answer. The most significant requirement is adding "plug and play" support to allow the master to cleanly detect and handle spontaneous disconnection of the device while in the middle of a transaction. One response from Cypress (from 2015) suggested adding a timer monitoring the output lines, but provided no additional info. Another in the same thread suggested creating a new component.
Can somebody provide me with a bit more detail on the recommended way to implement this timeout?
I would also like to request that this option be added to the standard I2C SCB component. There is an SMBus slave component so it seems reasonable to provide a standard implementation of an SMBus master.
Thank you,
Bill
Show LessHi
Is there a setting to force PSoC Creator4.2 to always perform a clean and build before programming?
I have found if I modify a file and program the device, without doing a "Clean and Build", the modified code is not always used.
It would seem, if a file other than main.c is modified then the old binary file is programmed in the device as the compiler doesn't generate a new binary file.
Regards
Pete
Show Less