سلام دوستان این سورس رو من از مثال های نمونه سایت دانلود کردم میخوام بجای ADC0.5 از ADC0.0 استفاده کنم
این خط رو به این شکل تغییر میدم
اما همش 0 دریافت میکنم در عمل
لطفا راهنماییم کنید
کد:
#include <lpc17xx.h> #define family_lpc17xx #define TFTLCD_DATAPORT_1 #define TFTLCD_DATAPORT_OFFSET 15 #define TFTLCD_CONTROLPORT_1 #define TFTLCD_RST 0 #define TFTLCD_RS 8 #define TFTLCD_CS 9 #define TFTLCD_RD 1 #define TFTLCD_WR 4 #define PORTRAIT #include "tftlcd_functions.h" #include <stdio.h> void delay (unsigned long tick) { /* Delay Function */ unsigned long dly = tick*300; while(dly--); } char s[20]; int i; int main(){ SystemInit(); tftlcd_init(); tftlcd_clear(); LPC_GPIO2->FIODIR = 0xfff; LPC_PINCON->PINSEL3 |= (3UL<<30); /* P1.31 is AD0.5 */ LPC_SC->PCONP |= (1<<12); /* Enable power to ADC block */ LPC_ADC->ADCR = (1<< 5) | /* select AD0.5 pin */ (4<< 8) | /* ADC clock is 25MHz/5 */ (1<<21); /* enable ADC */ while(1){ LPC_ADC->ADCR &= ~(7<<24); /* stop conversion */ LPC_ADC->ADCR |= (1<<24); /* start conversion */ while (!(LPC_ADC->ADGDR & (1UL<<31))); /* Wait for Conversion end */ i = (LPC_ADC->ADGDR>>4 & 0xfff); sprintf(s,"ADC:%d",i); tftlcd_gotoxy(7,10); tftlcd_puts(s,RED,GREEN,0); } }
کد:
LPC_PINCON->PINSEL1 |= (3UL<<14); LPC_SC->PCONP |= (1<<12); LPC_ADC->ADCR = (1<< 0) |
لطفا راهنماییم کنید
دیدگاه