Advertisement
maygapixel

Untitled

Dec 16th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.27 KB | None | 0 0
  1. #include "LPC214x.H"                                        // LPC2148 MPU Register
  2. #include <stdio.h>                                          // For Used Function printf
  3. #include "adc7.h"
  4.  
  5. void AD7Init(void)
  6. {  
  7.       PINSEL0 &= 0xFFFFF3FF;                                    // Select ADC7 Pin Connect P0.5
  8.       PINSEL0 |= 0x00000C00;                                   
  9.      
  10.       AD0INTEN=(0x100)|(7<<1);
  11.       AD0CR &= 0x00000000;                                      // Clear All Bit Control
  12.       AD0CR |= 0x00000080;                                      // Select ADC = AIN7
  13.       AD0CR |= 0x00000600;                                      // ADC Clock = VBP(PCLK) / 7
  14.       AD0CR |= 0x00010000;                                      // Busrt = 1 = Conversion Continue
  15.       AD0CR &= 0xFFF1FFFF;                                      // CLKS = 000 = 10Bit : 11 Cycle Clock Conversion
  16.       AD0CR |= 0x00200000;                                      // PDN = 1 = Active ADC Module
  17.       AD0CR &= 0xFF3FFFFF;                                      // TEST[1:0] = 00 = Normal Mode
  18.       AD0CR &= 0xF7FFFFFF;                                      // EDGE = 0 = Conversion on Falling Edge  
  19.       AD0CR |= 0x01000000;                                      // START = 001 = Start Conversion Now
  20.  
  21.         VICVectAddr4 = (unsigned)AD0isr;    //  //Set the timer ISR vector address
  22.         VICVectCntl4 = (0x20 | 18);     //  //Set channel
  23.         VICIntEnable |= (1 << 18);      //  //Enable the interrupt  
  24. }
  25.  
  26.  void AD0isr (void) __irq
  27. {  
  28.     val = (AD0DR7>>6) & 0x3E8; // (AD0DR6>>6) & 0x3ff;
  29.     val = (val + 50)/5;
  30.     VICVectAddr = 0;           
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement