How to run c++ embedded code on arm7(LPC2129) board using flash magic. I wrote LCD, LED, UART programming code by c++ , on Kiel uvision4(ie mdk472_a) compiler . In that I can do simulation, without any error and warning. But problem in compilation, I can dump code in ARM7 kite by using flash magic software, but i didn't get any output for LED, UART and LCD display and even though I changed delay... Please help me soon
My LCD display code... //this is HEADER.H #include<lpc21xx.h>
class lcd1 { public:
void lcd_init(); void lcd_cmd(unsigned char command); void lcd_data(unsigned char lcddata); void lcd_string(char *p); void delay(unsigned int value); };
//#include<lpc21xx.h> #include<string.h> #include"HEADER.h"
void lcd1::lcd_init() { IODIR1=0x03000000; IODIR0=0x00003C00; lcd_cmd(0x02); lcd_cmd(0x28); lcd_cmd(0x01); lcd_cmd(0x06); lcd_cmd(0x0f); lcd_cmd(0xC0); lcd_cmd(0x80); }
void lcd1::lcd_cmd(unsigned char command) { unsigned int value; //32 BIT
IOCLR1=0x03000000; //rs=0 en=0 value=(command & 0xf0); //8 bit value=value<<6; // shifting from 4 5 6 7 to 10 11 12 13 place(shifting by 6) IOSET0=value; //copy command to port pin IOCLR0=~value; //clear pins other than command pins IOCLR1=0x03000000; IOSET1=0x02000000; // en=1 delay(20); IOCLR1=0x02000000; //en=0
value=(command&0x0f); value=value<<10; //shifting from 0 1 2 3 to 10 11 12 13 place(shifting by 10) IOSET0=value; IOCLR0=~value; IOCLR1=0x03000000; IOSET1=0x02000000; delay(20); IOCLR1=0x02000000; }
void lcd1::lcd_data(unsigned char lcddata) { unsigned int value;
IOCLR1=0x03000000; //rs=0 en=0 value=(lcddata&0xf0); value=value<<6; IOSET0=value; //copy data to port pin IOCLR0=~value; //clear pins other than data pins IOCLR1=0x03000000; IOSET1=0x03000000; //rs=1 en=1 delay(20); IOCLR1=0x02000000; //en=0
IOCLR1=0x03000000; value=(lcddata&0x0f); value=value<<10; IOSET0=value; IOCLR0=~value; IOCLR1=0x03000000; IOSET1=0x03000000; delay(20); IOCLR1=0x02000000; }
void lcd1::delay(unsigned int value) { unsigned int i; for(i=0;i<value;i++); //for(j=0;j<5000;j++); }
void lcd1::lcd_string(char *p) { while(*p!='\0') { lcd_data(*p++); delay(2);
} }
int main() {
lcd1 l1; while(1) { l1.lcd_init(); l1.lcd_data('w'); //l1.lcd_string("Knowx Innovation"); } }
I can load this code on lpc2129 ARM7 kit, but problem on compilation, I can't see display. another one thing when I compile LCD C Programming code by using same kit, I got display output, but c++ code i didn't get output. Please give me solution for this problem...