Products > Programming

How do you master parsing Keil 5 project and write your own program?


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.

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.


--- Quote ---Keil is an IDE. It doesn't have any fixed folder structure.
--- End quote ---

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:

* Separation of the built "object" files and the user source code.  Sometimes, the generated files are further divided - intermediate files and final "Product" files, "debug" vs "production" builds, different configurations, etc.
* Separation of the user source code from vendor-provided source code. Well; usually.  In the case of ARM, you have user code, ARM code, chip-vendor code, and compiler-vendor (ie Keil) code.  They can be distributed across the folder structure in various ways.
* Special files that describe the "project configuration."
* Some care is usually taken to the "version control" of the various components.  Either carefully versioned vendor files (Keil uses "packs", and has a "pack manager"), or sometimes copying all of the vendor files into the project folder structure ("Atmel Start")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: ---C:\Users\billw\Documents\KeilProject1>tree /f
│   keilproject.uvoptx
│   keilproject.uvprojx
│   main.c

│       startup_samc21.lst

│       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

    │   └───ATSAMC21G18A
    │           startup_SAMC21.s
    │           system_samc21.c
--- End code ---

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"

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.


[0] Message Index

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod