Skip to main content
philipgillespie
Associate
November 5, 2010
Question

scanf on STM32

  • November 5, 2010
  • 4 replies
  • 866 views
Posted on November 05, 2010 at 13:27

scanf on STM32

    This topic has been closed for replies.

    4 replies

    Andrew Neil
    Super User
    May 17, 2011
    Posted on May 17, 2011 at 14:13

    For a specific question like this, about a specific toolset, you really should be asking on the tool's own support site!

    IIRC, RIDE has options to use a ''small printf'' or ''full printf'' - so you hve to RTFM to make sure all your settings are correct..

    Again, the guys at Raisonance are really the ones to ask!

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    John F.
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 14:13

    It should be ebough to include <stdio.h>. Check if your development environment has settings to use (or not) floating point support etc. Sometimes only simplified library functions are loaded by default (to save space).

    Tesla DeLorean
    Guru
    May 17, 2011
    Posted on May 17, 2011 at 14:14

    Under Keil the scanf/printf code eats more stack than the default projects provide for, and consequently crashes into the heap. Probably less of an issue with GNU based chains.

    Put in a real handler for the hard fault and you can find the offending code pretty quickly.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    infoinfo974
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 14:14

    how's about this...

    currently using the ''small printf'' in the project settings. Printf works fine no complaint there. Scanf compiles ok & the code executes to the point where the first character is sent via the keyboard. The character is echoed back (from within the __io_getchar just for debug purposes) ok.

    After that point the code fails jumping to 

    void

    HardFault_Handler(

    void

    ) & I think it's possibly because there's a formatted_read function that's not been linked correctly.

    I'd have though that the #inclusion of stdio.h would've been enough but that's why I'm wondering where scanf lives in the standard install?

    Cheers