projekty/Source/example1/src/timer.c

Go to the documentation of this file.
00001 /*
00002  * $Id: timer.c,v 1 2004/11/23 23:34:00 BorisK Exp $
00003  *
00004  * Copyright (C) 2004 ONTRACK s.r.o.
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA    
00019  * 02111-1307, USA.
00020  *
00021  * [1] ARM-based Microcontroller LPC2119/2129/2194/2292/9994, "Preliminary User Manual", February 03, 2004
00022  *
00023  * Written by Boris Kralik <kralikbo@yahoo.com>, 2004
00024  *
00025  */
00026 #include "timer.h"
00027 
00028 void StopTimer0(void)
00029 {
00030         T0_TCR  &=      2;
00031         #if 1
00032                 printf("\n\rStopTimer0(void)");
00033         #endif
00034 }
00035 void
00036 StartTimer0(void){
00037         // Start timer 0
00038         T0_TCR  |=      (1 << 0);       //Start TIMER0
00039         #if 1
00040                 printf("\n\rStartTimer0(void)");
00041         #endif
00042 }
00043 
00044 void StopTimer1(void)
00045 {
00046         T1_TCR  &=      2;
00047 }
00048 void
00049 StartTimer1(void){
00050         // Start timer 1
00051         T1_TCR |= (1 << 0);     // Counter enable
00052         #if 0
00053                 printf("\n\rStartTimer1");
00054         #endif
00055 }
00056 
00057 void 
00058 Timer1RegSet(void)
00059 {
00060         SCB_PCONP       |=      (1 << 2);       //Zap Timer 1
00061         // Reset timer 1 */
00062         T1_TCR = 0x0;   //Disable counter
00063         // Set the timer 1 prescale counter 
00064         T1_PR = 2500;   //Prescale counter register
00065         // Set timer 1 match register 
00066         T1_MR0 = 1000;  //Match register
00067         // Generate interrupt and reset counter on match 
00068         T1_MCR = (0x1 | 0x2) ;  //(3) Interrupt is generated when MR0 matches the value in the TC and will be reset MR0
00069         // Reset timer 1 */
00070         T1_TCR = ((1 << 0) | (1 << 1)); //Counter enable and reset
00071         #if 1
00072                 printf("\n\rTimer1RegSet");
00073         #endif
00074 }
00075 void 
00076 Timer0RegSet(void)
00077 {
00078         SCB_PCONP       |=      (1 << 1);       //Zap Timer 1
00079         T0_TCR = 0x0;   //Disable counter
00080         // Set the timer 0 prescale counter 
00081         T0_PR = 2500;   //Prescale counter register
00082         // Set timer 0 match register 
00083         T0_MR0 = 1000;  //Match register
00084         // Generate interrupt and reset counter on match 
00085         T0_MCR = (0x1 | 0x2);   //(3) Interrupt is generated when MR0 matches the value in the TC and will be reset MR0
00086         T0_TCR = ((1 << 0) | (1 << 1)); //Counter enable and reset
00087         #if 0
00088                 printf("\n\rTimer0RegSet");
00089         #endif
00090 }

Generated on Fri Sep 21 13:41:54 2007 for example1 by  doxygen 1.4.7