OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [altera_de0_nano_soc/] [software/] [libs/] [tA/] [timerA.c] - Blame information for rev 221

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 221 olivier.gi
#include "omsp_system.h"
2
#include "timerA.h"
3
 
4
//---------------------------------------------------//
5
//    TA_WAIT_NO_LPM                                 //
6
// ( the function implements a wait by continously ) //
7
// ( polling the TAR register                      ) //
8
//                                                   //
9
//---------------------------------------------------//
10
void ta_wait_no_lpm(unsigned int time_cnt) {
11
 
12
  // Start and re-initialize TimerA
13
  TACTL = TASSEL0 | TACLR | MC_2;
14
 
15
  // Wait until time is over
16
  while(TAR < time_cnt);
17
 
18
}
19
 
20
//--------------------------------------------------//
21
//    WAIT FUNCTION                                 //
22
// ( the function brings the core to LPM0 state )   //
23
// ( the timerA IRQ will exit the LPM0 state    )   //
24
//                                                  //
25
//--------------------------------------------------//
26
void ta_wait(unsigned int time_cnt) {
27
 
28
  // Set time limit for IRQ generation
29
  TACCR0 = time_cnt;
30
 
31
  // Start and re-initialize TimerA
32
  TACTL  = TASSEL0 | TACLR | MC_1 | TAIE;
33
 
34
  // Go to Low-Power-Mode 0
35
  LPM0;
36
 
37
}
38
 
39
//--------------------------------------------------//
40
//    TIMER A INTERRUPT                             //
41
//--------------------------------------------------//
42
wakeup interrupt (TIMERA1_VECTOR) INT_timerA1(void) {
43
 
44
  // Clear the receive pending flag & stop timer A
45
  TACTL = TAIFG;
46
 
47
  // Exit the low power mode
48
  LPM0_EXIT;
49
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.