PrintF output with MPlabX / XC8 / Debugger / Pic18F

Status
Not open for further replies.

Wp100

Well-Known Member
Hi,

Beginners question please ! is there a simple way to route the printF statements output to a window within MplabX debugger so we can get an immediate visual ?

Seen some web mention of DBPrint but that only seems to be for Pic32 , not accepted with pic18F.
 
You need to send the output to the uart and then to an output window... If you initialize then uart and write the putch(); to output to the uart.. When you open the serial output in MPLABX it will be displayed..

This is the test code..
C:
/*
* File:  uart test.c
* Author: Ian Rogers
*
* Created on 12 November 2014, 18:34
*/
#include <xc.h>
#include <stdio.h>
#include <stdlib.h>

void Serinit(void)
{
  TRISC = 0xFF;
  RCSTA = 0xB0;
  TXSTA = 0x24;
  SPBRG = 0x12;
}
void putch(char data)
{

  while(!TXIF);
TXREG = data;
}
/*
*
*/
void main() {
  char x;

  Serinit();

  while(1)
  {
  printf("Hello world \n\r");
  }

}

If you right click on your project... Select "Properties"... Select "Conf:[default]... select "Simulator" Then from the drop down box.... Select "USART IO Options" Tick the box and select window ( not file ) then you should see an output window when you debug...
 
Hi Ian,

Works perfectly, exactly what we were after, would have taken a year and a day to work that one out ! many thanks.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…