• AVR Freaks

Hot!PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ?

Page: 123 > Showing page 1 of 3
Author
ice_man
Starting Member
  • Total Posts : 69
  • Reward points : 0
  • Joined: 2013/01/15 07:51:29
  • Location: 0
  • Status: offline
2019/12/21 17:46:15 (permalink)
0

PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ?

Hi,
 
I try to find in stdio.h ant other files redirect uart possiblity, but I couldn't find it. I use XC16. I want send string for example uart number 3. I try to find solution on forum - without result.
 
Could You help me ? Thanks.
#1

47 Replies Related Threads

    ric
    Super Member
    • Total Posts : 26943
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 19:01:41 (permalink)
    0
    Did you look in the XC16 User Guide?
    Specifically "3.5.5 How Do I Redirect Standard I/O When Using Printf?"
     
    Note, you already have both
    MPLAB_XC16_C_Compiler_Users_Guide.pdf
    and
    16-Bit_Language_Tools_Libraries_Manual.pdf
    in the XC16 "docs" folder.
     
     

    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!
    #2
    ice_man
    Starting Member
    • Total Posts : 69
    • Reward points : 0
    • Joined: 2013/01/15 07:51:29
    • Location: 0
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 19:27:38 (permalink)
    0
    Hi, yes I have both documents, and I cant find where is precision information about it and where is the place in stdio.h where I can change that parameters.
    post edited by ice_man - 2019/12/21 19:29:05
    #3
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11813
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 20:03:18 (permalink)
    +1 (1)
    There are no circumstances where you  need to modify the system header files.
     
    Search for C30_UART in the libraries manual.
    #4
    ice_man
    Starting Member
    • Total Posts : 69
    • Reward points : 0
    • Joined: 2013/01/15 07:51:29
    • Location: 0
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 20:13:30 (permalink)
    0
    Is C30_UART  for pic 24 series ? 
    post edited by ice_man - 2019/12/21 20:14:53
    #5
    ric
    Super Member
    • Total Posts : 26943
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 20:14:48 (permalink)
    0
    Who told you to make the change in stdio.h?
    There is already code in libpic30.h to use UART2 rather than UART1.
    See: https://www.microchip.com/forums/FindPost/816504
     
    If you want to use any other UART (except 1 or 2), or some other device, then you need to edit source code in libpic30. This is described in chapter "2.13.2 Customizing STDIO" in 16-Bit_Language_Tools_Libraries_Manual.pdf
     

    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!
    #6
    ice_man
    Starting Member
    • Total Posts : 69
    • Reward points : 0
    • Joined: 2013/01/15 07:51:29
    • Location: 0
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 20:16:36 (permalink)
    0
    libpic30.h is ok for pic 24 series ?
    #7
    ric
    Super Member
    • Total Posts : 26943
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 20:27:06 (permalink)
    +1 (1)
    Did you bother reading the link I posted in #6 ?

    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
    ice_man
    Starting Member
    • Total Posts : 69
    • Reward points : 0
    • Joined: 2013/01/15 07:51:29
    • Location: 0
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 20:35:46 (permalink)
    0
    I'm reading, thanks for help. If I have a question I ask in this post.
    #9
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11813
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 21:31:35 (permalink)
    0
    you need to edit source code in libpic30

     
    You don't have to modify the library.  Your own open/write functions will override the library.  It's actually simpler than what's in the manual; you don't need all of the section/attribute stuff.  Also keep in mind this requires a heap.
    #10
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11813
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 21:32:29 (permalink)
    0
     
    Is C30_UART  for pic 24 series ?

     
    Yes.
    #11
    ric
    Super Member
    • Total Posts : 26943
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/21 21:33:27 (permalink)
    +1 (1)
    jtemples
    you need to edit source code in libpic30

     
    You don't have to modify the library.  Your own open/write functions will override the library.  It's actually simpler than what's in the manual; you don't need all of the section/attribute stuff.  Also keep in mind this requires a heap.

    Thanks John.
    To the OP, pay attention to what jtemples tells you. I'm just passing on what the documentation says, he's speaking from experience. :)
     

    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!
    #12
    du00000001
    Just Some Member
    • Total Posts : 3665
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/22 02:50:37 (permalink)
    0
    Do I recall incorrectly that you just have to provide a putch() function that's using the port of your choice?
    (Which would allow using e.g. an SPI port instead of a UART port as well.)

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #13
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3840
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/22 03:03:43 (permalink)
    -1 (1)
    In 8bit it is putch()
    Over-ride the 16bit C library function, "write".
    int __attribute__((__weak__, __section__(".libc.write"))) write(int FD, const void *Buffer, int Len){
        if(FD == 1){ //stdout
            for(int f=0; f<Len; f++){
                while(!(U1STAHbits.UTXBE));
                U1TXREG = *(char*)Buffer++;
            }
        }
        ..
        return Len;
    }

    Override - it is now a dos/windows standard function allowing strings to be written to the display or to a file.
    post edited by Gort2015 - 2019/12/22 03:39:56

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #14
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3840
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/22 03:35:08 (permalink)
    -1 (1)
    Some of the things that I incorporate into stdout/srderr etc.
    ASCII characters < 32 or > 126 can either be replaced with a period or ignored, replace CR with LF and CR (putty)
    Block ctrl codes.
    Convert to upper/lower case.
    Delays.
    Convert special characters in text to ansi sequences.
    qputs("\\col:red\\Gort", -10);
     
    "\033[34mGort"
     Gort
     

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #15
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3840
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/22 03:56:42 (permalink)
    -2 (2)
    volatile unsigned int *txreg = &U1TXREG + FD * uartblock_sizeof;
     
    With 4 uarts calculate the address of the uart block.
     
     
     

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #16
    ice_man
    Starting Member
    • Total Posts : 69
    • Reward points : 0
    • Joined: 2013/01/15 07:51:29
    • Location: 0
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/23 17:03:55 (permalink)
    0
    Hi,
     
    when I make some changes in libpic30.h, I can't save them - system information on picture. 
     
     

    Attached Image(s)

    #17
    ric
    Super Member
    • Total Posts : 26943
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/23 17:29:51 (permalink)
    0
    Try shutting down MPLABX, and editing it using another text editor program.
    Did you take note of jtemple's comments in post#10?

    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!
    #18
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3840
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/23 17:41:20 (permalink)
    -1 (3)
    I thought you were told by jtemples not to modify header files?
    post edited by Gort2015 - 2019/12/23 17:42:21

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #19
    ice_man
    Starting Member
    • Total Posts : 69
    • Reward points : 0
    • Joined: 2013/01/15 07:51:29
    • Location: 0
    • Status: offline
    Re: PIC 24FJ128GA202 - where I could redirect printf for one of four uart's ? 2019/12/24 15:06:03 (permalink)
    0
    ric
    Try shutting down MPLABX, and editing it using another text editor program.
    Did you take note of jtemple's comments in post#10?


    The same reaction. I think that isn't normal sytuation when I need edit c file in some text editor not in mplab/xc16. 
    Somebody have some idea how I can fix this problem ?
    #20
    Page: 123 > Showing page 1 of 3
    Jump to:
    © 2020 APG vNext Commercial Version 4.5