Errors with timers code for LPC2148

Status
Not open for further replies.

Surender Reddy

Full Member level 2
Joined
Jan 28, 2012
Messages
129
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Location
Bangalore, India
Activity points
2,186
i have downloaded a timer0/intterupt code from one website, when i try to build the code using keil 4 uvision with 12MHz crystal, it is giving errors as
Code:
inttrupt.c(6): error:  #20: identifier "PLLFEED" is undefined
inttrupt.c(13): error:  #20: identifier "PLLCFG" is undefined
inttrupt.c(15): error:  #20: identifier "PLLCON" is undefined
inttrupt.c(17): error:  #20: identifier "PLLSTAT" is undefined.

Here is my code:

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "LPC214x.h"
 
 void feed()
{
   
   PLLFEED |= 0xAA;
   PLLFEED |= 0x55;
}
 
void sys_init(void)
{
   // Configure PLL0: set CCLK (processor clock) to 60Mhz. Oscillator is 12Mhz
   PLLCFG |= 0x24;            
   feed();
   PLLCON |= 0x1;             
  feed();
   while(!(PLLSTAT & (1 << 10)));    
  PLLCON = 0x3;            
   feed();
   
   MAMTIM = 3;              
   MAMCR = 0x02;            
   
   VPBDIV = 2;               
   VICProtection = 0;            
VICIntSelect = 0;         
   MEMMAP = 0x01;            
   
   SCS = 3;               
}
 
void led_blink_ISR()
{   
   FIO1PIN ^= 1 << 24;            
   T1IR = 0xff;               
   VICVectAddr = 0;
}
 
void led_blink(unsigned int ms)
{
   static int isBlinking = 0;
   
   if(ms == 0) {
      VICIntEnClr |= (1 << 5);   
      VICVectAddr9 = 0;
      VICVectCntl9 = 0;
      T1TCR = 0;               
      FIO1SET |= 1 << 24;        
      isBlinking = 0;
      return;
   }
   
   if(isBlinking) {
            T1MR0 = ms;
      return;
   }
   
        // The LED is connected to P1.24: initialize it as a GPIO:output
        FIO1DIR |= 1 << 24;
        FIO1SET = 1 << 24;
 
   // Configure timer1 to generate an interrupt at ms/2
   T1TCR = 2;                  
   T1CTCR = 0;                  
   T1PR = 30000 - 1;            
   T1MCR = (1 << 0) | (1 << 1);   
   T1MR0 = ms;                  
   
   VICVectAddr9 = (unsigned long)led_blink_ISR;
   VICVectCntl9 = 5 | (1 << 5);
   VICIntEnable |= (1 << 5);      
   
   isBlinking = 1;
   
   T1TCR = 1;                 }
 
int main (void)
{
   sys_init();
        led_blink(100);   
        
        while(1);          
}



How to configure PLL register?
if you have codes for interrupt/timers please share it, thanks in advance
 
Last edited by a moderator:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…