HomeTOOLSEXAMPLESEXPLORE EMBEDDEDE CSERVICESECU SAMPLESRegistration
Embedded C programming Tutorial , Keil C ide , microsoftware.gr
Keil CRC and CAN BUS codes.
1. Shift led left
2.It's time for DAVE! <7/6/13>
3.Capture/Compare unit 6
4.ASC0-GPT1-MACROS
5.ASC0-FIFO-PEC
6.Analog converter
7.Memory manipulation routines
8. Recursion
9.Understanding interrupt priorities using CAPCOM2 module
10. POINTERS TO FUNCTION <4/7/13>,<4/28/13>
11.Memory models, memory types
12. The heap , part 1
13. The heap , part 2
14. The heap , part 3
15. Structure example
16. Nested structures, Array of structures.
17. Passing array of structures to function using pointers.<1/5/13>
18. Self Referential Structures
19. BITFIELDS
20. Linked list example
21. Circular linked list
22. Union example
23. Enumeration example
24. Watchdog timer example
25. Void pointer example <7/4/13>
26. The sieve of Eratosthenes
27. The stack
28. Union and bitfields as flags example. <6/23/13>
29. Look up table example. <8/11/13>
30. Seven segment display multiplexing -four digits with dot- example
31. LCD character display example - JHD162A
32. Hash table introduction example <8/27/14>
33. Array of Linked Lists example
34. Array of Linked lists-more functions included.
35. Hash table construction,searching and printing.
36. Fininte state machines- a first approach.
37. Finite state machines- two events example.
38. SPI port and an AT25128 serial eeprom hardware.
39. CRC CHECK
40. Definite Integral Calculator for Scientists, Engineers...
41 .Hamming distance of a CRC polynomial
42. Linux play starting.
43. Galois GF(2^4) Finite Field
44. Construct your own time triggered real time operating system.
45. CANBUS C CODE EXAMPLE.
18. Self Referential Structures

This article explains by example how a binary tree works.

A structure can't contain itself as a member, but it can include as members pointers to structures of the same type. Using this fact we can make  sequences of structures called branches of a binary tree. Each tree has a root node structur and two branches (sequence of structures). The branches are organized as left and right branch. Each node of a branch (a structure) may also be splited to left and right branches of nodes etc.
First, we pass data to the root node.
Second, we receive new data and we compare them, under a desired property, with the data of the root node. If they have the same property we count the similarity, else we put the new data to the left or right branch for a new comparison with new incoming data, etc. So, we can sort data under a property.

The example C code is included at the book of  Ted Van Sickle , pages 95 to 106 (an error :
you have to replace TNODE word with Tnode). Of course it needs a few of modifications to run. Malloc() needs to initialize the memory pool for allocation as we have a small amount of RAM memory inside of a microcontroller.
I have done some unimportant casts (we work with small integers) to stop compiler sounds for trunctated values.

We used      new library    functions included at <ctype.h> folder.


       The C code is here                                        the result

Example: Open Hyperterminal at 19200 kbaud,  print on the screen  aBcA  ,then 'enter' and after it zero (The microcontroller receives the integer 0x30 and stops asking for a new word to send). Then you will see on the screen how many times a letter is appeared in the word aBcA.
Upper-case letters are transformed to low- case letters by the program.
At the code I added and a breakpoint. It helps to the watch window.Remove it.



In my opinion: Ted Van Sickle's book is a wonderful and almost complete book, playing a hard
"Rock dance " music about C.  Enjoy!


 

Home|TOOLS|EXAMPLES|EXPLORE EMBEDDEDE C|SERVICES|ECU SAMPLES|Registration