LPC2148 problema quando ADC1.0 e ADC1.1 trabalhar juntos

H

hbaocr

Guest
# include "LPC214x.H" / / LPC2148 MPU Register
# include / / Para Usada função printf

/ Seção pototype * * /
init_serial0 void (void); / / initil UART-0
putchar (int ch); / / Put Char para UART-0
int getchar (void); / / Get Char De Uart-0
void delay (unsigned long int); / / Delay Time Function
unsigned int count;
tempx unsigned long int, tempy;
valx unsigned int / / Resultado ADC (HEX)
unsigned int valy;
float voltx / / ADC Resultado Volt
float Volty;
float ax, ay, um;int main (void)
(

PCONP | = 1 <<20; / / set Nguon cap PDA1 cho ADC1

init_serial0 (); / / UART0 inicial = 9600, N, 8,1

/ / chon ADC1.1 = P0.8 va ADC1.0 = P0.6
PINSEL0 | = 0x000033000; / / Select ADC8 Conectar-Pin P0.6

/ / ADC8 inicial (ADCR = 0x01210601)
AD1CR & = 0x00000000 / / Limpar todos os bits de controle
AD1CR | = 0x00000003; / / Select ADC1.1 va ADC1.0
AD1CR | = 0x00000600 / / ADC Clock = VBP (PCLK) / 7
AD1CR | = 0x00010000 / / Busrt = 1 = Conversão Continue
AD1CR & = 0xFFF1FFFF / / CLKS = 000 = 10 Bits: 11 ciclo de relógio de Conversão
AD1CR | = 0x00200000 / / PDN = 1 = Active ADC Module
AD1CR & = 0xFF3FFFFF / / TEST [1:0] = 00 = Modo Normal
AD1CR & = 0xf7ffffff / / EDGE = 0 = conversão em Queda Edge
AD1CR | = 0x01000000; / / start = 001 = Iniciar Conversão Agora
/ / P0.6 = Ax gia toc Theo truc x
/ / Start ADC8 teste de leitura e exibição em UART0 / /
while (1) / / Loop Continue
(
count = 1;
tempx = tempy = 0;
while (count -)
(
/ doc gia tri ADC1.0 ax = valx

fazer
(
valx = AD1DR0; / / Read A / D Data Registe-se e pouco clara FEITO
)
while (valx (& 0x80000000) == 0); / / Wait ADC Conversion Complete
valx = (valx>> 6) & 0x03ff;
/ / Printf (volt ");
/ Doc gia tri ADC1.1 ay = valy
do / / Loop Leia ADC1.1 (ADC8)
(
AD1DR1 valy =;
/ / Printf (voltx "1"); / / Read A / D Data Registe-se e pouco clara FEITO
)
while ((valy & 0x80000000) == 0); / / Wait ADC Conversion Complete

/ / loop porque ele sempre aqui

valy = (valy>> 6) & 0x03ff;
tempx = valx;
tempy = valy;
)
Volty tempy * = 3,3 / 1023.0/100.0;
voltx tempx * = 3,3 / 1023.0/500.0;
printf ( "voltx =% 1.2f \ n", voltx);
printf ( "VOLY =% 1.2f \ n", Volty);
delay (10000);
)
)

/******************************/
/ * UART0 inicial = 9600, N, 8,1 * /
/ * VPB (pclk) = 60,00 MHz * /
/******************************/
init_serial0 void (void)
(
PINSEL0 & = 0xFFFFFFF0; / P0.0 / Reset, P0.1 Pin Config
PINSEL0 | = 0x00000001; / / Select = P0.0 TxD (UART0)
PINSEL0 | = 0x00000004; / / Select P0.1 = RxD (UART0)

U0LCR & = 0xFC / / Redefinir o Word Select (1:0)
U0LCR | = 0x03; / / Bit de dados = 8 bits
U0LCR & = 0xFB / / Stop Bit = 1 Bit
U0LCR & = 0xF7; / Paridade / = Disable
U0LCR & = 0xBF; / / Break Desativar Controle
U0LCR | = 0x80; / / Enable Programação do Divisor Travas

/ / U0DLM: U0DLL = 60,00 MHz / [16 x Baud]
/ / = 60,00 MHz / [16 x 9600]
/ / = 390,6 = 391 = 0187H
U0DLM = 0x01 / / Programa Divisor Latch (391) para 9600 Baud
U0DLL = 0x87;

U0LCR & = 0x7F; / Programação / Disable do Divisor Travas

U0FCR | = 0x01; / fif0 Ativar
U0FCR | = 0x02; / RX FIFO Reset
U0FCR | = 0x04; / / TX FIFO Reset
U0FCR & = 0x3F;
)

/****************************/
/ * Character Escreve Para UART0 * /
/****************************/
putchar (int ch)
(
if (ch == '\ n')
(
while (! (U0LSR & 0x20)); / / Wait TXD buffer vazio
U0THR = 0x0D; / / Write CR
)
while (! (U0LSR & 0x20)); / / Wait TXD buffer vazio
return (U0THR = ch); / / Write Character
)

/*****************************/
/ * Caractere lido a partir UART0 * /
/*****************************/
int getchar (void)
(
while (! (U0LSR & 0x01)); / / Wait RxD Recepção de Dados Pronto
return (U0RBR); / / Get Receice Data & Return
)

/***********************/
/ * Delay Time Function * /
/ * 1-4294967296 * /
/***********************/
void delay (unsigned long int count1)
(
while (count1> 0) (count1 -;) / / Loop Diminuir Counter
)

 
hbaocr escreveu:

# include "LPC214x.H" / / LPC2148 MPU Register

# include / / Para Usada função printf/ Seção pototype * * /

init_serial0 void (void); / / initil UART-0

putchar (int ch); / / Put Char para UART-0

int getchar (void); / / Get Char De Uart-0

void delay (unsigned long int); / / Delay Time Function

unsigned int count;

tempx unsigned long int, tempy;

valx unsigned int / / Resultado ADC (HEX)

unsigned int valy;

float voltx / / ADC Resultado Volt

float Volty;

float ax, ay, um;int main (void)

(PCONP | = 1 <<20; / / set Nguon cap PDA1 cho ADC1init_serial0 (); / / UART0 inicial = 9600, N, 8,1/ / chon ADC1.1 = P0.8 va ADC1.0 = P0.6

PINSEL0 | = 0x000033000; / / Select ADC8 Conectar-Pin P0.6/ / ADC8 inicial (ADCR = 0x01210601)

AD1CR & = 0x00000000 / / Limpar todos os bits de controle

AD1CR | = 0x00000003; / / Select ADC1.1 va ADC1.0

AD1CR | = 0x00000600 / / ADC Clock = VBP (PCLK) / 7

AD1CR | = 0x00010000 / / Busrt = 1 = Conversão Continue

AD1CR & = 0xFFF1FFFF / / CLKS = 000 = 10 Bits: 11 ciclo de relógio de Conversão

AD1CR | = 0x00200000 / / PDN = 1 = Active ADC Module

AD1CR & = 0xFF3FFFFF / / TEST [1:0] = 00 = Modo Normal

AD1CR & = 0xf7ffffff / / EDGE = 0 = conversão em Queda Edge

AD1CR | = 0x01000000; / / start = 001 = Iniciar Conversão Agora

/ / P0.6 = Ax gia toc Theo truc x

/ / Start ADC8 teste de leitura e exibição em UART0 / /

while (1) / / Loop Continue

(

count = 1;

tempx = tempy = 0;

while (count -)

(

/ doc gia tri ADC1.0 ax = valxfazer

(

valx = AD1DR0; / / Read A / D Data Registe-se e pouco clara FEITO

)

while (valx (& 0x80000000) == 0); / / Wait ADC Conversion Complete

valx = (valx>> 6) & 0x03ff;

/ / Printf (volt ");

/ Doc gia tri ADC1.1 ay = valy

do / / Loop Leia ADC1.1 (ADC8)

(

AD1DR1 valy =;

/ / Printf (voltx "1"); / / Read A / D Data Registe-se e pouco clara FEITO

)

while ((valy & 0x80000000) == 0); / / Wait ADC Conversion Complete/ / loop porque ele sempre aquivaly = (valy>> 6) & 0x03ff;

tempx = valx;

tempy = valy;

)

Volty tempy * = 3,3 / 1023.0/100.0;

voltx tempx * = 3,3 / 1023.0/500.0;

printf ( "voltx =% 1.2f \ n", voltx);

printf ( "VOLY =% 1.2f \ n", Volty);

delay (10000);

)

)/******************************/

/ * UART0 inicial = 9600, N, 8,1 * /

/ * VPB (pclk) = 60,00 MHz * /

/******************************/

init_serial0 void (void)

(

PINSEL0 & = 0xFFFFFFF0; / P0.0 / Reset, P0.1 Pin Config

PINSEL0 | = 0x00000001; / / Select = P0.0 TxD (UART0)

PINSEL0 | = 0x00000004; / / Select P0.1 = RxD (UART0)U0LCR & = 0xFC / / Redefinir o Word Select (1:0)

U0LCR | = 0x03; / / Bit de dados = 8 bits

U0LCR & = 0xFB / / Stop Bit = 1 Bit

U0LCR & = 0xF7; / Paridade / = Disable

U0LCR & = 0xBF; / / Break Desativar Controle

U0LCR | = 0x80; / / Enable Programação do Divisor Travas/ / U0DLM: U0DLL = 60,00 MHz / [16 x Baud]

/ / = 60,00 MHz / [16 x 9600]

/ / = 390,6 = 391 = 0187H

U0DLM = 0x01 / / Programa Divisor Latch (391) para 9600 Baud

U0DLL = 0x87;U0LCR & = 0x7F; / Programação / Disable do Divisor TravasU0FCR | = 0x01; / fif0 Ativar

U0FCR | = 0x02; / RX FIFO Reset

U0FCR | = 0x04; / / TX FIFO Reset

U0FCR & = 0x3F;

)/****************************/

/ * Character Escreve Para UART0 * /

/****************************/

putchar (int ch)

(

if (ch == '\ n')

(

while (! (U0LSR & 0x20)); / / Wait TXD buffer vazio

U0THR = 0x0D; / / Write CR

)

while (! (U0LSR & 0x20)); / / Wait TXD buffer vazio

return (U0THR = ch); / / Write Character

)/*****************************/

/ * Caractere lido a partir UART0 * /

/*****************************/

int getchar (void)

(

while (! (U0LSR & 0x01)); / / Wait RxD Recepção de Dados Pronto

return (U0RBR); / / Get Receice Data & Return

)/***********************/

/ * Delay Time Function * /

/ * 1-4294967296 * /

/***********************/

void delay (unsigned long int count1)

(

while (count1> 0) (count1 -;) / / Loop Diminuir Counter

)
 

Welcome to EDABoard.com

Sponsor

Back
Top