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.
4.ASC0-GPT1-MACROS

This article explains the ASC0, the timer module GPT1 and how you can use MACROS in your program.


ASC means asynchronous/synchronous interface. Inside the ic there are two ASC. ASC0 and ASC1. We will use ASC0 at full duplex mode (separate Tx and Rx, transmit and receive, pins). Tx and Rx pins are conected to IC MAX232 on the board. The reason is that xc164cm has logic states +5v and 0v, but the serial port of your computer has +12v and -12v. So it is needed to change the voltage levels of the logic states. This is common in practice and for other serial communication methodes like CANBUS and LIN.

Gpt1 is a three timers module that includes timers T2, T3 and T4. We will use T2 as a timer (timers can be used and as counters). When T2 reaches an underfow or overflow pre-determinted by the
program value then we have an interrupt.

At this example we use  MACROS,  in the file MAIN.C lines 310 and 313 , their definitions are in the file  GPT1.H  . To find the definitions of the MACRO right click on it at MAIN.C and select 'Go to definition of...'  at the opened window.
An other MACRO is in the file GPT1.C line 233. Find its definition.

The example program.
Run it. You can start or stop timer T2 sending to ASC0  '0' or '1' using HyperTerminal at 19.200 baud.
You have to connect the serial port of the development board with the serial port of your computer.
You ,may be, need a serial to USB cable. 
Observe the selections opening the project by DAVE. Observe the level of interrupt.

Exercise :  change the MACRO at line 233 with that at line 231 in the file GPT1.C and run again. Find the definitions of MACROS.
 


 

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