- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
the printf function does not send out the characters.
I added this function for redirect printf:
int __io_putchar(int ch)
{
UART_PutChar(ch);
return ch;
}
must I enable something ?
Best regards
Solved! Go to Solution.
- Labels:
-
PSoC 4 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Hi, the problem was the heap size, I changed from 0x80 to 0x200, now it works well.
Thanks
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
LuBe,
Can you get a terminal output if you use UART_PutChar(ch) directly?
If not, the problem may be that you haven't chosen the correct pin for the UART Tx.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
yes, the function UART_PutChar(ch) works well, but the printf does not work.
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Lube,
Please refer:
https://japan.cypress.com/documentation/code-examples/ce224431-psoc-4-uart-printf
You need to define the _write function for printf, not __io_putchar.
Shima
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have tested your example with success, but if I insert the same function write(...) in my project no work:
the write() function is not called.
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I think it was _write() instead of write()...
I wonder if my memo below can be some hint?
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
yes, I wrote write() but the implementation is this:
#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_PutChar(*(ptr++));
}
return(len);
}
#endif /* (__GNUC__) */
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
From your previous message, UART_PutChar(ch) is working,
so UART_Start() should have been called and UART seems to be ready.
Then you wrote that "write()" is not called.
I wonder in which source file you have your "_write()" function?
When I tried, I placed may "_write()" in my main.c,
although it may not be beautiful.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I wrote _write() in main.c. I have noticed that when I call printf the code entry in hard fault:
CY_ISR(IntDefaultHandler)
{
/***************************************************************************
* We must not get here. If we do, a serious problem occurs, so go into
* an infinite loop.
***************************************************************************/
if (errno == ENOMEM)
{
#ifdef CY_BOOT_INT_DEFAULT_HANDLER_ENOMEM_EXCEPTION_CALLBACK
CyBoot_IntDefaultHandler_Enomem_Exception_Callback();
#endif /* CY_BOOT_INT_DEFAULT_HANDLER_ENOMEM_EXCEPTION_CALLBACK */
while(1)
{
/* Out Of Heap Space
* This can be increased in the System tab of the Design Wide Resources.
*/
}
}
else
#endif
{
#ifdef CY_BOOT_INT_DEFAULT_HANDLER_EXCEPTION_ENTRY_CALLBACK
CyBoot_IntDefaultHandler_Exception_EntryCallback();
#endif /* CY_BOOT_INT_DEFAULT_HANDLER_EXCEPTION_ENTRY_CALLBACK */
{
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Have you expanded the stack/heap space?
Would you try / play with my memo in my previous response?
It can be memory space problem or some unhandled interrupt is called (or hit)
By any chance can you post a project which can be used to reproduce your problem?
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Hi, the problem was the heap size, I changed from 0x80 to 0x200, now it works well.
Thanks
Best regards