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.
|