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
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
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.
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.
6.Analog converter

This article explains how the analog converter works.

The XC164CM provides an Analog/Digital Converter with 8-bit or 10-bit resolution and a sample & hold circuit on-chip. An input multiplexer selects between up to 14 analog input channels (alternate functions of Port 5) either via software (fixed channel modes) or automatically (auto scan modes).

Part one: using the simulator
First, you have to write a script file to make a variable voltage applied at pin AN0 (Analog converter zero). This voltage begins from a value of 5 volts and goes down by steps of 0.5 volts. It is the SQ.INI file.
Your travell: // after debuging >>Debug>Function Editor (open Ini file). 
see the image
Second, after debug, you have to call this function, writing SQ() at the command window.
see it.

Take the C code.

Run it, open the serial window #1 and watch the resault.

Becarefull when you will reconfigure the project by DAVE: You have to replace line 173 made by DAVE at ASC0.C file ,with that of line 178. The problem comes from the printf function (at<stdio.h>) who calls putchar function. Printf is written for ASC0. You have to modifiy it if you want to use it with ASC1 ( see KEIL page).

Part two: using the debuger

 ...take it here. The program exports the voltage value at pin AN0 via ASC0 at Hyperterminal on your screen. Hyperterminal must be at 9,600 Kbaud.