EEVblog Electronics Community Forum

Products => Computers => Programming => Topic started by: bjdhjy888 on September 05, 2019, 07:28:43 am

Title: How do you master parsing Keil 5 project and write your own program?
Post by: bjdhjy888 on September 05, 2019, 07:28:43 am
I've seen some Keil 5 projects and managed to read some codes.
I also followed some video tutorials.
But man, I feels it's kindda more difficult than the hardware part(circuits, PCB layout, soldering).

For example, a Keil 5 project consists of lots of folders like Basic, LED, etc. Then, you have the main.c
As a beginner, I feel being overwhelmed. Not to mention writing my own project the way I want.

What would you do to master Keil programming, starting as a beginner, who knows some grammar of C and C++? Thanks.
 :-\
Title: Re: How do you master parsing Keil 5 project and write your own program?
Post by: ataradov on September 05, 2019, 10:50:30 am
Keil is an IDE. It doesn't have any fixed folder structure.

The folder structure you are talking about probably cones from some framework. So you need to read documentation for that framework.

Keil itself will happily build a single main.c file. You might need to install a device pack for your device to build something useful, of course.
Title: Re: How do you master parsing Keil 5 project and write your own program?
Post by: westfw on September 08, 2019, 08:51:40 am
Quote
Keil is an IDE. It doesn't have any fixed folder structure.

Huh?  In my experience, it is usually the IDE that has some sort of concept of a "project" that DOES impose a folder structure.
A folder structure that is frustratingly inconsistent between different IDEs :-(  (That's OK.  Big, popular, non-embedded software projects have inconsistent folder structures as well!  Sigh,)

However, there are some things that tend to be common:

In general, the IDE will manage the directory structure for you, and all you have to do is use the appropriate "add file" command, which will create the file in the appropriate spot AND tell the IDE that it is part of the project.

I dusted off my Keil install, which I used for a class once (and never had to actually create new projects), and created a trivial SAMC21 project.  After the "new project" dialog (being sure to create a new directory for the project - some IDEs will do that by default), which includes chip selection, and picking various intermediate-level code (in this case "redirect stdout"), I just "added C file" main.c, and did a build, and got this:

Code: [Select]
C:\Users\billw\Documents\KeilProject1>tree /f
C:.
│   keilproject.uvoptx
│   keilproject.uvprojx
│   main.c

├───Listings
│       keilproject.map
│       startup_samc21.lst

├───Objects
│       keilproject.axf
│       keilproject.build_log.htm
│       keilproject.htm
│       keilproject.lnp
│       keilproject_Target 1.dep
│       main.crf
│       main.d
│       main.o
│       retarget_io.crf
│       retarget_io.d
│       retarget_io.o
│       startup_samc21.d
│       startup_samc21.o
│       system_samc21.crf
│       system_samc21.d
│       system_samc21.o

└───RTE
    ├───Device
    │   └───ATSAMC21G18A
    │           startup_SAMC21.s
    │           system_samc21.c
    │
    └───_Target_1
            RTE_Components.h


main.c is up there in the top-level directory where it'll be obvious, along with te project description files.  Then there's a separate directory for Listings (human consumable output), and one for Objects (machine consumable output.)
startup... and system... are down in a "Run Time Envionment diretory"
Title: Re: How do you master parsing Keil 5 project and write your own program?
Post by: ataradov on September 08, 2019, 09:21:04 am
Some imposed structure for the output files and general project layout - sure. But Keil does not care where you put Basic or LED. This comes from a framework, for sure.