翻譯 這段用C語言寫的程式

#include <m8c.h>

#include "PSoCAPI.h"

void delay(unsigned int x);

void prvOut(signed long a);

void prAD590(signed long a);

void prLM35(signed long a);

void main()

{

unsigned int iData,j,gain;

signed long vData;

float iiData,resolution=1.3/2048;

M8C_EnableGInt;

ADCINC12_Start(ADCINC12_HIGHPOWER);

ADCINC12_GetSamples(0);

PGA_SetGain(PGA_G2_00);

gain=2;

PGA_Start(PGA_HIGHPOWER);

LCD_Start();

while(1)

{

iiData=0;

for (j=0;j<=9;j++)

{

delay(5000);while(ADCINC12_fIsDataAvailable() == 0);

ADCINC12_ClearFlag();

iData=ADCINC12_iGetData();

iData=((iData&0x0FFF)+2048)&0x0FFF; LCD_Position(0,0);

LCD_PrHexInt(iData);

iiData=iiData+iData;

}

iiData=iiData/10;

iiData=iiData*resolution/gain*100000;

vData=iiData;

LCD_Position(0,5);

prvOut(vData);

LCD_Position(1,0);

LCD_PrCString("AD590=");

prAD590(vData);

LCD_Position(2,0);

LCD_PrCString("LM35 =");

prLM35(vData);

}

}

void delay(unsigned int x)

{

unsigned int i;

for ( i = 0;i < x;i++ ) ;

}

void prvOut(signed long a){

unsigned long Data;

Data=a;

LCD_WriteData(Data/100000+0x30);

LCD_PrCString(".");

Data=Data%100000;

LCD_WriteData(Data/10000+0x30);

Data=Data%10000;

LCD_WriteData(Data/1000+0x30);

Data=Data%1000;

LCD_WriteData(Data/100+0x30);

Data=Data%100;

LCD_WriteData(Data/10+0x30);

Data=Data%10;

LCD_WriteData(Data/1+0x30);

LCD_PrCString("V");

}

Update:

可以說明 詳細一點嗎? 沒一句 後面用 // 隔開 說明 盡量用中文^^" 3Q

1 Answer

Rating
  • Anonymous
    1 decade ago
    Favorite Answer

    #include <m8c.h>

    #include "PSoCAPI.h"

    void delay(unsigned int x); 延遲

    void prvOut(signed long a); Data=a,lcd 顯示X.XXXXXV

    void prAD590(signed long a);

    void prLM35(signed long a);

    void main()

    {

    unsigned int iData,j,gain;

    signed long vData;

    float iiData,resolution=1.3/2048; ADC 之resolution

    M8C_EnableGInt;

    ADCINC12_Start(ADCINC12_HIGHPOWER);

    ADCINC12_GetSamples(0);

    PGA_SetGain(PGA_G2_00);

    gain=2;

    PGA_Start(PGA_HIGHPOWER); setting adc pga

    LCD_Start(); 起動 lcd panel

    while(1)

    {

    iiData=0;

    for (j=0;j<=9;j++)

    {

    delay(5000);while(ADCINC12_fIsDataAvailable() == 0); delay waitting adc samples

    ADCINC12_ClearFlag();

    iData=ADCINC12_iGetData(); got the adc data

    iData=((iData&0x0FFF)+2048)&0x0FFF; LCD_Position(0,0); set lcd character position

    LCD_PrHexInt(iData); 16數字轉整數

    iiData=iiData+iData;

    }

    iiData=iiData/10;

    iiData=iiData*resolution/gain*100000;

    vData=iiData;

    LCD_Position(0,5); 以下LCD顯示ADC590 SAMPLES DATA AND LM35 DATA

    prvOut(vData);

    LCD_Position(1,0);

    LCD_PrCString("AD590=");

    prAD590(vData);

    LCD_Position(2,0);

    LCD_PrCString("LM35 =");

    prLM35(vData);

    }

    }

    void delay(unsigned int x)

    {

    unsigned int i;

    for ( i = 0;i < x;i++ ) ;

    }

    ;SHOW A DATA ON LCD PANEL

    void prvOut(signed long a){

    unsigned long Data;

    Data=a;

    LCD_WriteData(Data/100000+0x30);

    LCD_PrCString(".");

    Data=Data%100000;

    LCD_WriteData(Data/10000+0x30);

    Data=Data%10000;

    LCD_WriteData(Data/1000+0x30);

    Data=Data%1000;

    LCD_WriteData(Data/100+0x30);

    Data=Data%100;

    LCD_WriteData(Data/10+0x30);

    Data=Data%10;

    LCD_WriteData(Data/1+0x30);

    LCD_PrCString("V");

    }

Still have questions? Get your answers by asking now.