• AVR Freaks

Hot!Is there consol output or some similar feature in MPLAB IDE X ?

Author
semir_ver
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2014/01/27 15:08:57
  • Location: 0
  • Status: offline
2014/08/07 12:21:33 (permalink)
0

Is there consol output or some similar feature in MPLAB IDE X ?

I have in some threads using virtual UART for sending to some
control Window. Something as using simulator.
But I can't find any valid example.
I suppose that is possible use this virtual  Uart to sending infor to
consol output window in debbugin phase.
Can anybode explain ?
Thank in advance
 
#1

9 Replies Related Threads

    bosco
    Super Member
    • Total Posts : 2119
    • Reward points : 0
    • Joined: 2004/07/24 10:17:53
    • Location: Idaho
    • Status: offline
    Re: Is there consol output or some similar feature in MPLAB IDE X ? 2014/08/07 13:07:42 (permalink)
    0
    That kind of feature is always a property of the debugger, both the debug executive inside the chip, and the external debugger.  
    Only the RealIce has "Trace" functionality (I believe, only available on 24/33/32Mx parts).
    Another option is to use a hardware UART and redirect stdout to that UART and use printf.
    but, that method is invasive unless using high baud rates or a DMA method and printf incurs a code size hit.
     
    newer ARM have semi-hosting and trace macro cell so the output does go to an Eclipse console
    #2
    semir_ver
    Starting Member
    • Total Posts : 43
    • Reward points : 0
    • Joined: 2014/01/27 15:08:57
    • Location: 0
    • Status: offline
    Re: Is there consol output or some similar feature in MPLAB IDE X ? 2014/08/07 13:16:44 (permalink)
    0
    Thank you for answer.
    Have you any link or give short description how to use it.
    For example I want assign one of existing Uart (but no in hardware) to this function and this
    way use "putch", "putstring" and similar string function to output window in order to follow
    progaram execution. Of course only in debugger phase
     
    Regards
    #3
    ric
    Super Member
    • Total Posts : 23859
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Is there consol output or some similar feature in MPLAB IDE X ? 2014/08/07 15:59:41 (permalink)
    0
    I think you have misread the previous answer.
    Bosco was saying you DO need a real hardware UART.
    The only "virtual" facility is with a RealICE on PIC 24/33/32Mx parts.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    semir_ver
    Starting Member
    • Total Posts : 43
    • Reward points : 0
    • Joined: 2014/01/27 15:08:57
    • Location: 0
    • Status: offline
    Re: Is there consol output or some similar feature in MPLAB IDE X ? 2014/08/07 16:09:01 (permalink)
    +1 (1)
    Thank you for answer . Maybe I don't understand well.
    I asked for UART but my question remain:
    Is there any way to have some type of consol output where I can sent my
    codes in order to simple follow program. ?
     
    Thank in advance
    #5
    sjb741
    Super Member
    • Total Posts : 805
    • Reward points : 0
    • Joined: 2010/01/25 08:45:39
    • Location: 0
    • Status: offline
    Re: Is there consol output or some similar feature in MPLAB IDE X ? 2014/08/10 07:17:11 (permalink)
    +2 (2)
    Hi,

    If you just want to output to the UART window (or file),

    Project | properties | Simulator | UART I/O Options: Enable "to window"
    PIC24, dsPIC33 etc
       void putch(char c) //Needed to make printf() work
       {
           while(!U1STAbits.TRMT);
           U1TXREG = c;
           Nop();
       }//putch
       
       void Open_SIM_Uart(void)
       {
          U1MODEbits.UARTEN = 1; //Must do this UART setup, even for simulator I/O
          U1STAbits.UTXEN = 1; //Open the file
       }//Open_SIM_Uart
       
       void Close_SIM_Uart(void)
       {
          U1STAbits.UTXEN = 0; //Close the file
       }//Close_SIM_Uart

    PIC16 etc
       void Open_SIM_Uart(void)
       {
          SPEN = 1; //Must do this UART setup, even for simulator I/O
          TXEN = 1; //Open the file
       }//Open_SIM_Uart
       
       void Close_SIM_Uart(void)
       {
          SPEN = 0; //Close the file
       }//Close_SIM_Uart

       void putch (char c) //Needed to make printf() work
       {
           while (!TRMT);
           TXREG = c;
       }

    int main(void)//PIC16: void main(void)
    {
       Open_SIM_Uart();
       printf("hello");
       Close_SIM_Uart();//Only need for FILE i/o (simulator writes to "DOS File")
    }//main

    Output appears in the "Output" Window (UART1 tab).

    For limitations, see my post - and replies from Microchip here
        
    Regards
    Stephen.  

    Attachment(s)

    Attachments are not available: Download requirements not met
    #6
    semir_ver
    Starting Member
    • Total Posts : 43
    • Reward points : 0
    • Joined: 2014/01/27 15:08:57
    • Location: 0
    • Status: offline
    Re: Is there consol output or some similar feature in MPLAB IDE X ? 2014/08/31 12:05:54 (permalink)
    0
    Hi Stephen
    Thank you very match. Sorry, I didn't see before you answer because
    in this period I was absent (vacation).
    You answer is just what I needed.
    I didn't try, but I am a little unsure.
    Should I include some special library for using for 24F family?
    How will compilar "know" that is is virtual UART, but not real?
    From first glance I can see the same instruction for UART access.
    If you are willing, we can discuss by PM ()
    Thank you one more 
    Regards
     
    #7
    ric
    Super Member
    • Total Posts : 23859
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Is there consol output or some similar feature in MPLAB IDE X ? 2014/08/31 14:24:37 (permalink)
    +1 (1)
    semir_ver
    How will compilar "know" that is is virtual UART, but not real?

    It doesn't. You are compiling code for accessing a real UART.
    It is the simulator that is intercepting access to the real UART.
     

    If you are willing, we can discuss by PM ()

    Please do not ask for private help. The whole idea of a forum is to have questions and answers in public.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    sjb741
    Super Member
    • Total Posts : 805
    • Reward points : 0
    • Joined: 2010/01/25 08:45:39
    • Location: 0
    • Status: offline
    Re: Is there consol output or some similar feature in MPLAB IDE X ? 2014/09/01 08:07:33 (permalink)
    0
    Hi Semir
     
    In "main.c" are
    #include<xc.h>    //Always needed
    #include<stdio.h> //For "printf" prototype

     
    The projects are self-contained - it should be enough to un-zip and run the project. If you try one of the "zip" projects, I think it will make sense.
     
    • "Should I include some special library for using for 24F family?" --> No - not required.
     
    Regards
    Stephen
    #9
    sjb741
    Super Member
    • Total Posts : 805
    • Reward points : 0
    • Joined: 2010/01/25 08:45:39
    • Location: 0
    • Status: offline
    Re: Is there consol output or some similar feature in MPLAB IDE X ? 2019/06/18 01:20:34 (permalink)
    0
    Just tried this again today. I accidentally forgot to use the initialisation code. But (in XC16) it worked fine: The output appears in the UART1 window.
     
    #include<xc.h>
    #include<stdint.h>
    #include<stdio.h>
    #include<string.h>

    void debug(void)
    {
       int8_t i, j;
       
       for(i=-5; i<=5; i++)
       {      
          for(j=-3; j<=3; j++)   
          {
             if(j != 0)
                printf("(%d %% %d) = %d\n", i, j, i%j);  
          }
       }
       printf("\n-------------------\n");   
    }//debug

    int main(void)
    {
       debug();
       
       for(;;)
       {

       }     
    }//main


    post edited by sjb741 - 2019/06/18 01:44:35
    #10
    Jump to:
    © 2019 APG vNext Commercial Version 4.5