Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "LPC214x.H" // LPC2148 MPU Register
- #include <stdio.h> // For Used Function printf
- #include "adc7.h"
- //#include "uart0.h"
- /* pototype section */
- //void init_serial0 (void); // Initil UART-0
- //int putchar (int ch); // Put Char to UART-0
- //int getchar (void); // Get Char From Uart-0
- //void delay(unsigned long int); // Delay Time Function
- //void AD0isr (void) __irq;
- //unsigned int val; // ADC Result (HEX)
- //unsigned int status0;
- void AD7Init(void)
- {
- //init_serial0(); // Initial UART0 = 9600,N,8,1
- //TimerInit();
- //printf("CP-JR ARM7 USB-LPC2148...TEST ADC7(P0.5)\n"); // Call prinff Function
- //printf("Input Voltage 0-3.3V to P0.5 For Test\n"); // Call prinff Function
- // Initial ADC7 (GPIO-0.5) By Set PINSEL0[11:10=11]
- // xxxx xxxx xxxx xxxx xxxx 11xx xxxx xxxx
- PINSEL0 &= 0xFFFFF3FF; // Select ADC7 Pin Connect P0.5
- PINSEL0 |= 0x00000C00;
- // Initial ADC0 (ADCR=0x01210680)
- //AD0INTEN = 0x180;//(1 << 7); // Disable ADC Interrupt
- AD0INTEN=(0x100)|(7<<1);
- AD0CR &= 0x00000000; // Clear All Bit Control
- AD0CR |= 0x00000080; // Select ADC = AIN7
- AD0CR |= 0x00000600; // ADC Clock = VBP(PCLK) / 7
- AD0CR |= 0x00010000; // Busrt = 1 = Conversion Continue
- AD0CR &= 0xFFF1FFFF; // CLKS = 000 = 10Bit : 11 Cycle Clock Conversion
- AD0CR |= 0x00200000; // PDN = 1 = Active ADC Module
- AD0CR &= 0xFF3FFFFF; // TEST[1:0] = 00 = Normal Mode
- AD0CR &= 0xF7FFFFFF; // EDGE = 0 = Conversion on Falling Edge
- AD0CR |= 0x01000000; // START = 001 = Start Conversion Now
- VICVectAddr4 = (unsigned)AD0isr; // //Set the timer ISR vector address
- VICVectCntl4 = (0x20 | 18); // //Set channel
- VICIntEnable |= (1 << 18); // //Enable the interrupt
- /// / // Start Test Read ADC0 and Display on UART0 //
- // while(1) // Loop Continue
- // {
- // } ;
- }
- void AD0isr (void) __irq
- {
- val = (AD0DR7>>6) & 0x3E8; // (AD0DR6>>6) & 0x3ff;
- val = (val + 50)/5;
- //printf("ADC7 Result = %d \n",val);
- //TimerInit();
- //T0MR0 = (val-1);
- VICVectAddr = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment