This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

AR7 TDmi-s Program Problem

HI a am an student having Problem in understanding program
please help me

// Program to convert the analog data into digital data using the ADC section.
// Connect P0.0-0.7 with ADC Control
// Conect P0.8-0.15 with ADC data
// Connect P0.16-0.23 with LCD data
// Control P0.24-P0.31 with LCD control

#include <LPC210x.h>

#define PLOCK 0x0400
#define TIME 20000

#define DISP_FUNC 0x38 // sets the display to 8-bit, 2 lines, 5x7 chars + cursor-off
#define DISP_ENTRY 0x06
#define DISP_CNTL 0x0E
#define DISP_ON 0x04
#define DISP_CURSOR 0x02
#define DISP_CLEAR 0x01
#define DISP_HOME 0x02
#define DISP_POS 0x80
#define DISP_BLINK 0x01
#define DISP_SECOND 0xC0
#define OE 0x01 // sets the display to 8-bit, 2 lines, 5x7 chars + cursor-off
#define SOC 0x02
#define ALE 0x04
#define EOC 0x00000008
#define SET0 0x10
#define SET1 0x20
#define SET2 0x40
#define CLOCK 0x80

//#define LED_ON IOCLR |= 0xFFFFFFFF
//#define LED_OFF IOSET |= 0x00000080

unsigned long b,d,e;
unsigned char temp[5];
void Init(void);
void Delay (unsigned long a);

signed char i;
char string[16]= " Advance Tech.";
char string1[16]="Digital O/P ";

//---------------------------------------------------------
// System initializations
//---------------------------------------------------------
void Init() { // Init PLL PLLCFG=0x23; // P=2, M=4, PLLfreq = 235,9296 Mhz, CCLK = 64 Mhz PLLFEED=0xAA; PLLFEED=0x55; PLLCON=0x1; // Enable the PLL PLLFEED=0xAA; PLLFEED=0x55; while(!(PLLSTAT & PLOCK)); // Wait for PLL to lock PLLCON=0x3; // Connect PLL as clock source PLLFEED=0xAA; PLLFEED=0x55; //Init MAM & Flash memory fetch MAMCR=0x2; //mam = flash MAMTIM=0x4; VPBDIV=0x1; //pclk = cclk //GPIO init IODIR=0xFFFF00F7; //P0.7 is output(LED)
}

void Delay (unsigned long e)
{ while (--e!=0);
}

void inswrt(char c)
{ b = (c << 16)|(0x02<<24); IOSET=b; IOCLR = 0x02000000; IOCLR = 0xFFFFFFFF; Delay(TIME);
} void datawrt(char c)
{ b = (c << 16)|(0x03<<24); IOSET=b; IOCLR = 0x03000000; IOCLR = 0xFFFFFFFF; Delay(TIME);
}

void clock(void)
{ unsigned int a,b; for(b=0;b<=200;b++) { for(a=0;a<800;a++); IOSET=0x00000080; for(a=0;a<800;a++); IOCLR=0x00000080; }
} //---------------------------------------------------------
// RESET entry
//---------------------------------------------------------

int main() { Init(); IOCLR = 0xFFFFFFFF; Delay(TIME); inswrt(DISP_FUNC); inswrt(DISP_CNTL); inswrt(DISP_ENTRY); inswrt(DISP_CLEAR); for (i=0;i<15;i++) datawrt(string[i]); inswrt(DISP_SECOND); for (i=0;i<15;i++) datawrt(string1[i]); while(1) { IOCLR=0xFF00FFFF; IOSET=SET0; IOSET=SET1; IOSET=SET2; IOSET=ALE; IOSET=SOC; clock(); IOCLR=ALE; IOCLR=SOC; clock(); IOPIN = IOPIN & 0x00000000;

while(IOPIN==0x00000000); IOPIN = IOPIN & 0x00000000; IOSET=OE; d=IOPIN; d=d & 0x0000FF00; d=d>>8; d=d&0x000000FF; inswrt(0xCC); for(i=0;i<3;i++) { temp[i]=d%10; d=d/10; }

for(i=3;i>=0;i--) { datawrt(temp[i]+0x30); }

}
}

what is program does
in while(1) loop
and how and when we use-
IOSET
IOPIN
IODIR
IOCLR

Please Reply me

Parents
  • "//" represents the start of a comment. All text to the end of the line will be ignored by the compiler.

    "Program to convert the analog data into digital data using the ADC section."

    ...

    Wait a minute - don't you think you have to tell us exactly _what_ you do not understand about this program? How exactly do you think anyone can help you if you don't explain your problem?

    By the way: Did you read the information text directly above the text box where you wrote your post? Did you see the information about how to post source code?

    How about trying to post your code so it looks like:

    #include <stdio.h>
    
    int main(void) {
        printf("Hello world!\n");
        return 0;
    }
    

Reply
  • "//" represents the start of a comment. All text to the end of the line will be ignored by the compiler.

    "Program to convert the analog data into digital data using the ADC section."

    ...

    Wait a minute - don't you think you have to tell us exactly _what_ you do not understand about this program? How exactly do you think anyone can help you if you don't explain your problem?

    By the way: Did you read the information text directly above the text box where you wrote your post? Did you see the information about how to post source code?

    How about trying to post your code so it looks like:

    #include <stdio.h>
    
    int main(void) {
        printf("Hello world!\n");
        return 0;
    }
    

Children
No data