[SOLVED]MPLAB X IDE Console/File output - Page 1
Forum section: electronics / general

author: NightMoth
author_rank: Contributor
timestamp: April 07, 2025, 08:05:28 am
content: Hello allI'm using:- MPLAB X IDE v5.50- xc8 v3.00 compiller (c99, Uart1 IO enabled in project properties)For debugging and for testing logic of my code, I want some output to be displayed on some console of MPLAB IDE or to be written into file.(I don't plan use microcontroller to output this data, just want to see what my code do. I will remove from code all output related routines before making hex file)I found this microchip article that described how do do it with fprint() function:https://developerhelp.microchip.com/xwiki/bin/view/software-tools/xc8/simulator-consoleI copypasted code from anove article, but can't compille it.Here is the code and error message:CodeCode:#include <xc.h>#include <stdio.h>void putch(unsigned char data){while( ! PIR1bits.TXIF) // wait until the transmitter is readycontinue;TXREG = data; // send one character}void init_uart(void) {TXSTAbits.TXEN = 1; // enable transmitterRCSTAbits.SPEN = 1; // enable serial port}void main(void) {init_uart();printf("Hello world\ntest value is %04d\n", 23);while(1)continue;}Error messages:CLEAN SUCCESSFUL (total time: 34ms)make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-confmake: Entering directory 'F:/MY_ELECTRONIC_PROJECTS/PIC_Projects/TestProject_01.X'make -f nbproject/Makefile-default.mk dist/default/production/TestProject_01.X.production.hexmake: Entering directory 'F:/MY_ELECTRONIC_PROJECTS/PIC_Projects/TestProject_01.X'"C:\Program Files\Microchip\xc8\v3.00\bin\xc8-cc.exe" -mcpu=16F877A -c -mdfp="C:/Program Files/Microchip/MPLABX/v5.50/packs/Microchip/PIC16Fxxx_DFP/1.2.33/xc8" -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/TestProject_01.p1 TestProject_01.cTestProject_01.c:12:6: error: conflicting types for 'putch'12 | void putch(unsigned char data)| ^C:\Program Files\Microchip\xc8\v3.00\pic\include\c99/stdio.h:106:6: note: previous declaration is here106 | void putch(char);| ^1 error generated.nbproject/Makefile-default.mk:107: recipe for target 'build/default/production/TestProject_01.p1' failedmake: Leaving directory 'F:/MY_ELECTRONIC_PROJECTS/PIC_Projects/TestProject_01.X'nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failedmake: Leaving directory 'F:/MY_ELECTRONIC_PROJECTS/PIC_Projects/TestProject_01.X'nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failedmake: *** [build/default/production/TestProject_01.p1] Error 1make: *** [.build-conf] Error 2make: *** [.build-impl] Error 2BUILD FAILED (exit value 2, total time: 968ms)Am I putting putch() function into wrong place?I will very appreciate if somebody advice how I can make program output displayed with MPLAB IDE (or written into file).I don't want to use last version of MPLAB IDE, because it doesn't support PicKit3.5+ I own.

author: westfw
author_rank: Super Contributor
timestamp: April 07, 2025, 07:37:41 pm
content: What happens if you get rid of the "unsigned" in your function declaration?

author: NightMoth
author_rank: Contributor
timestamp: April 08, 2025, 12:00:02 am
content: Quote from: westfw on April 07, 2025, 07:37:41 pmThank you! It works now.I should have checked xc8 manual first. In the manual they indeed use "char" as input to putch(), not "unsigned char".