- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
I can only print data using UART_UartPutString() function,but i can not use printf() function to print data,no error,but print nothing.
Is something i did not do?
#include "stdio.h"
heap is set as 0x200
UART_UartPutString( "Hello World!\r\n" );
printf("HI World!\r\n");
Thanks,
Leo
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Leo,
Please refer to below link.
Thanks
Lucas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Leo,
Please refer to below link.
Thanks
Lucas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi Lucas:
What you provide the link , it can use in psoc4200 and high Muc, but in psoc4000 &PSOC4000S , the IDE has no compont of UART_2.5. Just has uart(scb), so can't use you example;
i find an example of PSOC4200 of printf;
CE224431;
and i copy this below code to pso4000s , it can;t work ,
#include <stdio.h>
#if defined (__GNUC__)
/* Add an explicit reference to the floating point printf library to allow
use of floating point conversion specifier. */
asm (".global _printf_float");
/* For GCC compiler revise _write() function for printf functionality */
int _write(int file, char *ptr, int len)
{
/* Warning suppression for unused function parameter */
file = file;
int i;
/* Character is sent via UART */
for (i = 0; i < len; i++)
{
UART_UartPutChar(*(ptr++));
}
return(len);
}
#endif /* (__GNUC__) */
/* Start UART operation */
UART_Start();
printf(helloworld\r\n");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Once, I wrote the following topic
printf and float rhapsody (aka, yet another printf and floating topic)
Today I tried it with CY8CKIT-145-40xx (CY8C4045AZI-S413)
main.c (Note: we need to provide an implementation of _write())
==============
#include "project.h"
#include "stdio.h"
int _write(int file, char *ptr, int len)
{
(void) file ;
int i ;
for (i = 0 ; i < len ; i++) {
UART_UartPutChar(*ptr++) ;
}
return len ;
}
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
UART_UartPutString("\r\nHello From UART\r\n") ;
printf("Hi from printf()\r\n") ;
for (;;) {
}
}
==============
Tera Term Log (Sorry, I could not get rid of the garbage at the top ...)
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear DaZh-san,
First of all, an important WARNING!
============================
In the "Touch.zip" you attached a file named "CE210289_CapSense_P4_Linear_Slider01_timing.html" seemed to be infected.
I recommend you to run a virus scan on your PC to get rid of the potential threat(s).
============================
Now returning to the main story.
I've already written this in my previous post
printf and float rhapsody (aka, yet another printf and floating topic)
===================
(2.2) Expand the heap
Project > Design Wide Resources > System
Heap Size (byte) 0x80 -> 0x200 (value may vary depending on your requirement)
=============
The heap size of your project was "0x80", which was the default size.
You need to double click the "System" in the "Design Wide Recources" in your Project Explorer.
And double clock the "Value" field of Heap Size and modify it from "0x80" to "0x200"
or some value big enough to work with "printf()"
I tested your project with my board which has CY8C4146LQI-S433,
as right now this one is the closest to your device as far as I can access.
I modified your main.c and added a debug line using UART_UartPutString().
=======================
UART_UartPutString("printf test with heap 0x80\r\n") ;
while(1)
{
printf("Hi from printf()\r\n") ;
CyDelay(300);
}
=======================
Then when I ran with the heap size of 0x80, the output was
And when I ran with the heap size of 0x200, the output was
Attached is your project with the heap size of 0x200.
moto