You need to set Project->Buid Settings->ARM->Linker "use newlib nano float formatting" to true.
Hi and thanks for your reply.
Setting "use newlib nano float formatting" to true, didn't help. After further investigation I think the problem is not with the printf function, but rather with some internals of the UART.
I attach another archived project which receives UART data I enter from a terminal, puts it in rx_buffer array, then it calculates the uint32 TimerPeriod value of the received data. Then it sends that value back to terminal with printf.
The first time I enter the data it displays a wrong value. But if I continue to enter the same data again several times, the value is displayed correctly. The problem with the wrong value being displayed occurs only when I enter new data for the first time and the change involves more than the first byte to be sent from terminal through UART.
The problem I have and determined me to ask for your help is that when I use the debugger, every time and every data I enter, the result is displayed correctly, no erroneous display. Hence the debugger is not helping much with the investigation.
You can try it with the attached code.
I downloaded a fresh UART full duplex example (CE210741), I changed the device for the one I have (CY8C5888LTI-LP097) and changed the pins to match the target:
- LED on P2.1
- Switch on P2.2
- Rx on P12.6
- Tx on P12.7
I programmed the kit with no other modification and it works as described, all typed characters returned to terminal.
However, I discovered that if I disconnect the USB cable from the programmer and I power externally the kit, the application doesn't run at all. After I introduce the characters at terminal and hit Enter, the "Error" LED turns ON and of course no characters are received back.
Is it the kit programmed with the example delivered in CE210741 meant not to work independently? Is it some sort of IP protection, or it may be related to the problem I found?
Please disregard the printf function, this is not the issue.
After further investigation the issue looks to be that implementation of UART component is assuming that it will be used for bootloadable applications only.
I started a new project with the goal of replicating the example CE210741, but without all unnecessary config and .h files. Only UART, ISR, and SW + LED pins. The main.c was largely copy/paste from CE210741. Test results were like before, when USB cable is plugged, data was transmitted back to Terminal, and without USB cable, the error LED was turned ON and no data received.
After building the project, I noticed the presence of UART_BOOT.c. The stated purpose of being generated " This file provides the source code of bootloader communication APIs for the UART component."
While I understand some applications will need this feature, in my opinion, for the purpose of stand alone application this is more like a hindrance. Again, in my opinion, this "feature" interferes and a regular (not bootable data) UART transfer depends on the presence of the KitProg.
Could anyone please give an idea for a workaround?
The target device communicates with the PC USB host via the Kitprog. The Kitprog serves as a USB-UART bridge and hence even if you power your board externally, without the Kitprog, there is no direct link between the target device UART lines and the PC USB host lines as shown below:
This is the reason you didn't see anything on the terminal. More information on the Kitprog can be found here: http://www.cypress.com/file/157966/download