Thread: C Programming on STM32 Embedded System (microcontroller)

  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    2

    Post C Programming on STM32 Embedded System (microcontroller)

    “The C Programming Language, Kernighan and Ritchie” isconsidered as best book to learn C Programming. It’s lots of example.

    STM32-Nucleo is apopular microcontroller board to do embedded programming.

    I have run all the examples from the book on STM32-Nucleo.

    You can find the code here in GitHub.

    This will help people learn C programming on embeddedsystem/microcontroller.

  2. #2
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    I haven't read through everything there, but the whole thing about EOF is wrong, to say the least: KernighanRitchieAndSTm32/EndofFile.md at master * akd-jls/KernighanRitchieAndSTm32 * GitHub

    EOF means end of file. Ctrl-D is just a way to tell a process in a *nix system reading from a terminal that the end of file has been reached. All that typing Ctrl-D in a terminal does is causes the process to read zero bytes (the read() syscall returns 0), which is translated to "EOF" inside the C stdio. Redefining EOF to 0x04 is the wrong way to go about that, especially if you expect your library to work properly with actual files (say, on an SD card). The proper way to handle end-of-file in a terminal is to "cook" the user input in a similar way to *nix; the simplest approach is to make getchar() return EOF when it reads Ctrl-D from a terminal.

  3. #3
    Registered User
    Join Date
    Dec 2019
    Posts
    2

    Thanks

    Quote Originally Posted by christop View Post
    I haven't read through everything there, but the whole thing about EOF is wrong, to say the least: KernighanRitchieAndSTm32/EndofFile.md at master * akd-jls/KernighanRitchieAndSTm32 * GitHub

    EOF means end of file. Ctrl-D is just a way to tell a process in a *nix system reading from a terminal that the end of file has been reached. All that typing Ctrl-D in a terminal does is causes the process to read zero bytes (the read() syscall returns 0), which is translated to "EOF" inside the C stdio. Redefining EOF to 0x04 is the wrong way to go about that, especially if you expect your library to work properly with actual files (say, on an SD card). The proper way to handle end-of-file in a terminal is to "cook" the user input in a similar way to *nix; the simplest approach is to make getchar() return EOF when it reads Ctrl-D from a terminal.
    Thanks a Christop for valuable input. I got your point. I will update the code accordingly.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Microcontroller Programming
    By PFactorial in forum C Programming
    Replies: 4
    Last Post: 08-17-2011, 04:33 PM
  2. Replies: 4
    Last Post: 07-10-2005, 02:01 PM
  3. Microcontroller Programming With C
    By Garfield in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 11-18-2001, 02:06 PM
  4. Microcontroller Programming With C
    By Garfield in forum C Programming
    Replies: 20
    Last Post: 11-17-2001, 05:04 PM
  5. microcontroller programming
    By wazilian in forum C Programming
    Replies: 3
    Last Post: 10-12-2001, 02:22 PM

Tags for this Thread