Skip to main content
Visitor II
March 30, 2006
Question

cosmic functions

  • March 30, 2006
  • 9 replies
  • 1866 views
Posted on March 30, 2006 at 09:44

cosmic functions

    This topic has been closed for replies.

    9 replies

    Visitor II
    March 18, 2004
    Posted on March 18, 2004 at 22:53

    hi there

    how do you make cosmic functions like getchar and putchar work?

    ive rewritten the c source files and built them but it doesnt work

    the files i changed were -

    \COSMIC\CXST7\srcst7\MODC\LIBI\getchr.c & putchr.c

    \COSMIC\CXST7\srcst7\MODM\LIBI\getchr.c & putchr.c

    \COSMIC\CXST7\srcst7\MODS\LIBI\getchr.c & putchr.c

    ive then run build.bat in each directory- but nothing happens

    my check sum doesnt change when i change the files either.

    what am i doing wrong??

    thanks for your help

    chris

    Visitor II
    March 19, 2004
    Posted on March 19, 2004 at 05:08

    If you want to customize putchar and getchar functions there's no need to touch the libraries.

    The best is to proceed as follows:

    - add a file to your project

    - write into this file the custom version of putchar and getchar

    - don't forget to include this file into the list of files to be linked (if you forget, the project will link anyway, but standard putchar and getchar will be used instead of yours, giving the feeling the system is not doing what you want)

    Hope this helps,

    Regards,

    Luca

    [ This message was edited by: _luca on 19-03-2004 09:39 ]
    Visitor II
    March 21, 2004
    Posted on March 21, 2004 at 22:36

    thanks Luca

    getchar and putchar works now, but i now get an error when using printf:- ''1 segment .share size overflow (10

    ''.

    got any ideas?

    cheers

    chris

    Visitor II
    March 22, 2004
    Posted on March 22, 2004 at 02:12

    .share stores the local variables of functions. The compiler takes care to ''overlap'' ram area used by two or more independent functions(which are not called at the same time). There is an overflow of this segment in your case, when using the printf function.

    Visitor II
    October 1, 2004
    Posted on October 01, 2004 at 07:27

    Hi everybody!

    I'm new to MCU programming. Your discussion about putchar and getchar is very interesting for me because I would like to use the ST7 simulator and capture the standard output. Namely, I need to log all the strings emitted through the function printf into a file.

    Can you please tell me how do I have to rewrite putchr.c to do it?

    Thanks

    Ivan
    Visitor II
    October 1, 2004
    Posted on October 01, 2004 at 11:17

    Hi,

    there's no need to touch any C function, this is a debugger/simulator problem. I know how to do it with ZAP (Cosmic debugger), but never tried with STVD7.

    Regards,

    Luca

    Visitor II
    October 4, 2004
    Posted on October 04, 2004 at 11:57

    Hi,

    Thank you for having answered but I can't understand how It could be! I took a look in the source code for the library; the function putchar appears to have an empty body.

    On the other side, however, the ''ST7 user manual'' ( one of the manuals packaged with cosmic compiler, page 143 ) says that...

    ''putchar is packaged in the integer library, and is by default using the

    first serial port SCI 1''. So, it seems that there has to be a way to capture standard output using the SCI 1.

    Now, if the SCI 1 serial port is the one I have to observe, how can I do it?

    Thank you

    Ivan

    Visitor II
    October 4, 2004
    Posted on October 04, 2004 at 12:10

    sorry if I didn't explain clearly.

    You first have to rewrite putchar to redirect the output of printf ''somewhere''. This somewhere is usually the UART, and the beginning of this thread explain how to do the redirection.

    Once you have done this, capturing the output is a problem for the debugger/simulator, and how you do it depends on the debugger you are using...

    If you want more details you can contact me offline, my contact info is

    http://www.cosmicsoftware.com/it/contact.php

    (top of the page, under ''Italy'')

    Regards,

    Luca

    Visitor II
    March 30, 2006
    Posted on March 30, 2006 at 09:44

    Hi Luca,

    I'm var new to MCU programming. Your discussion on writing to a file is very useful. I want to write a char buffer to a file.

    I am Using Cosmic compiler and Zap simulator.

    can you assist me.

    Thanks in advance...

    Regards,

    jaffar