Hello friends, I need your help
have time programming code for 8051 (c51) in keil and have no problem
but now I would like to start with arm, specifically with LPC2138 and I want to convert the code I show is written for 8051
but I can not do start All I know is how to define ports and little else.
I swear I've tried but have not succeeded.
the code is for a led matrix display and Works fine
please can help me?
the arm is no attempt to use the uart
thank you very much
the code in 8051 is:
//crystal is 22-24MHz //was made for Keil compiler #include #define BAUDRATE 9600 sbit Cclock=P1^1; sbit Clatch=P1^0; sbit Cdata=P3^7; sbit Row1=P1^2; sbit Row2=P1^3; sbit Row3=P1^4; sbit Row4=P1^5; sbit Row5=P1^6; sbit Row6=P1^7; sbit Row7=P3^2; sbit Row8=P3^3; unsigned int shift_delay; unsigned char code font[96][16] = { /* character 0x0020 (' '): (width=7, offset=0) */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* character 0x0021 ('!'): (width=8, offset=14) */ {0XFF,0XE,0X78,0X78,0XE0,0XFF}, /* character 0x0022 ('"'): (width=8, offset=30) */ {0x00, 0xE0, 0xE0, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* character 0x0023 ('#'): (width=8, offset=46) */ {0x00, 0x22, 0xFF, 0xFF, 0x22, 0xFF, 0xFF, 0x22, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x80, 0x00}, /* character 0x0024 ('$'): (width=8, offset=62) */ 0x00, 0x61, 0xF1, 0x98, 0x8C, 0xC7, 0x43, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, /* character 0x0025 ('%'): (width=8, offset=78) */ {0xC0, 0xE3, 0x26, 0xED, 0xDB, 0x32, 0x63, 0x01, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x80}, /* character 0x0026 ('&'): (width=8, offset=94) */ {0x00, 0x6F, 0xFF, 0x90, 0xF4, 0x67, 0x07, 0x04, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80}, /* character 0x0027 ('''): (width=8, offset=110) */ {0x00, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x03, 0x0F, 0x1C, 0x10, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x1C, 0x04, 0x00, 0x00}, /* character 0x0029 (')'): (width=8, offset=0) */ {0x00, 0x00, 0x10, 0x1C, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x1C, 0xF8, 0xE0, 0x00, 0x00}, /* character 0x002A ('*'): (width=8, offset=16) */ {0x00, 0x01, 0x05, 0x07, 0x03, 0x07, 0x05, 0x01, 0x00, 0x00, 0x40, 0xC0, 0x80, 0xC0, 0x40, 0x00}, /* character 0x002B ('+'): (width=8, offset=32) */ {0x00, 0x01, 0x01, 0x07, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00}, /* character 0x002C (','): (width=8, offset=48) */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x3C, 0x38, 0x00, 0x00}, /* character 0x002D ('-'): (width=8, offset=64) */ {0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* character 0x002E ('.'): (width=8, offset=80) */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x00, 0x00}, /* character 0x002F ('/'): (width=8, offset=96) */ {0x00, 0x00, 0x00, 0x01, 0x07, 0x1E, 0x18, 0x00, 0x00, 0x18, 0x78, 0xE0, 0x80, 0x00, 0x00, 0x00}, /* character 0x0030 ('0'): (width=8, offset=112) */ {0x00, 0x00, 0x0F, 0x1F, 0x10, 0x16, 0x1F, 0x0F, 0x00, 0x00, 0xE0, 0xF0, 0xD0, 0x10, 0xF0, 0xE0}, /* character 0x0031 ('1'): (width=8, offset=128) */ {0x00, 0x04, 0x04, 0x0C, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00}, /* character 0x0032 ('2'): (width=8, offset=144) */ {0x00, 0x0C, 0x1C, 0x10, 0x11, 0x1F, 0x0E, 0x00, 0x00, 0x30, 0x70, 0xD0, 0x90, 0x10, 0x10, 0x00}, /* character 0x0033 ('3'): (width=8, offset=160) */ {0x00, 0x0C, 0x1C, 0x11, 0x11, 0x1F, 0x0E, 0x00, 0x00, 0x60, 0x70, 0x10, 0x10, 0xF0, 0xE0, 0x00}, /* character 0x0034 ('4'): (width=8, offset=176) */ {0x00, 0x00, 0x1F, 0x1F, 0x00, 0x07, 0x07, 0x00, 0x00, 0xC0, 0xC0, 0x40, 0x40, 0xF0, 0xF0, 0x40}, /* character 0x0035 ('5'): (width=8, offset=192) */ {0x00, 0x1F, 0x1F, 0x11, 0x11, 0x11, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x30, 0xE0, 0xC0, 0x00}, /* character 0x0036 ('6'): (width=8, offset=208) */ {0x00, 0x03, 0x07, 0x1E, 0x1A, 0x13, 0x01, 0x00, 0x00, 0xE0, 0xF0, 0x10, 0x10, 0xF0, 0xE0, 0x00}, /* character 0x0037 ('7'): (width=8, offset=224) */ {0x00, 0x10, 0x10, 0x11, 0x17, 0x1E, 0x18, 0x00, 0x00, 0x00, 0x70, 0xF0, 0x80, 0x00, 0x00, 0x00}, /* character 0x0038 ('8'): (width=8, offset=0) */ {0x00, 0x0E, 0x1F, 0x13, 0x11, 0x1F, 0x0E, 0x00, 0x00, 0xE0, 0xF0, 0x10, 0x90, 0xF0, 0xE0, 0x00}, /* character 0x0039 ('9'): (width=8, offset=16) */ {0x00, 0x0F, 0x1F, 0x10, 0x10, 0x1F, 0x0F, 0x00, 0x00, 0x00, 0x90, 0xB0, 0xF0, 0xC0, 0x80, 0x00}, /* character 0x003A (':'): (width=8, offset=32) */ {0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x00, 0x00}, /* character 0x003B (';'): (width=8, offset=48) */ {0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x3C, 0x38, 0x00, 0x00}, /* character 0x003C ('<'): (width=8, offset=64) */ {0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x10, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x10, 0x00}, /* character 0x003D ('='): (width=8, offset=80) */ {0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00}, /* character 0x003E ('>'): (width=8, offset=96) */ {0x00, 0x10, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00, 0x10, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00}, /* character 0x003F ('?'): (width=8, offset=112) */ {0x00, 0x0C, 0x1C, 0x11, 0x13, 0x1E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xB0, 0x00, 0x00, 0x00}, /* character 0x0040 ('@'): (width=8, offset=128) */ {0x0F, 0x1F, 0x10, 0x11, 0x13, 0x12, 0x1F, 0x0F, 0xE0, 0xF0, 0x10, 0x90, 0xD0, 0x50, 0xD0, 0xD0}, /* character 0x0041 ('A'): (width=8, offset=144) */ {0x7F, 0xFF, 0x88, 0x88, 0xFF, 0x7F }, /* character 0x0042 ('B'): (width=8, offset=160) */ {0xFF, 0xFF, 0x81, 0x99, 0xDB, 0x7E}, /* character 0x0043 ('C'): (width=8, offset=176) */ {0xFF, 0xFF, 0x81, 0x81, 0xC3, 0xC3}, /* character 0x0044 ('D'): (width=8, offset=192) */ {0xFF, 0xFF, 0xC3, 0xC3, 0x7E, 0x3C}, /* character 0x0045 ('E'): (width=8, offset=208) */ {0xFF, 0xFF, 0xDB, 0xDB, 0xDB, 0xC3}, /* character 0x0046 ('F'): (width=8, offset=224) */ {0xFF, 0xFF, 0x88, 0x88, 0x88, 0x80}, /* character 0x0047 ('G'): (width=8, offset=240) */ {0x7E, 0xFF, 0x81, 0x89, 0xEF, 0x6F}, /* character 0x0048 ('H'): (width=8, offset=256) */ {0xFF, 0xFF, 0x08, 0x08, 0xFF, 0xFF}, /* character 0x0049 ('I'): (width=8, offset=272) */ {0xC3, 0xC3, 0xFF, 0xFF, 0xC3, 0xC3}, /* character 0x004A ('J'): (width=8, offset=288) */ {0x06, 0x07, 0x01, 0x01, 0xFF, 0xFE}, /* character 0x004B ('K'): (width=8, offset=304) */ {0xFF, 0xFF, 0x18, 0x3C, 0x66, 0xC3}, /* character 0x004C ('L'): (width=8, offset=320) */ {0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03}, /* character 0x004D ('M'): (width=8, offset=336) */ {0XFF,0XE0,0X78,0X78,0XE0,0XFF}, /* character 0x004E ('N'): (width=8, offset=352) */ {0xFF, 0xFF, 0x38, 0x1C, 0xFF, 0xFF}, /* character 0x004F ('O'): (width=8, offset=0) */ {0x7E, 0xFF, 0x81, 0x81, 0xFF, 0x7E}, /* character 0x0050 ('P'): (width=8, offset=16) */ {0xFF, 0xFF, 0xD8, 0xD8, 0xF8, 0xF8}, /* character 0x0051 ('Q'): (width=8, offset=32) */ {0x7E, 0xC3, 0x81, 0x85, 0xC2, 0x7D}, /* character 0x0052 ('R'): (width=8, offset=48) */ {0xFF, 0xFF, 0x88, 0x8C, 0xFF, 0x73}, /* character 0x0053 ('S'): (width=8, offset=64) */ {0x72, 0xF3, 0xDB, 0xDB, 0xCF, 0x46}, /* character 0x0054 ('T'): (width=8, offset=80) */ {0xC0, 0xC0, 0xFF, 0xFF, 0xC0, 0xC0}, /* character 0x0055 ('U'): (width=8, offset=96) */ {0xFE, 0xFF, 0x01, 0x01, 0xFF, 0xFE}, /* character 0x0056 ('V'): (width=8, offset=112) */ {0xF8, 0xFE, 0x07, 0x07, 0xFE, 0xF8}, /* character 0x0057 ('W'): (width=8, offset=128) */ {0xFF, 0x03, 0x3C, 0x3C, 0x03, 0xFF}, {0x11, 0x0a, 0x04, 0x0a, 0x11}, //X {0xC0, 0x60, 0x1F, 0x1F, 0x60, 0xC0}, //Y {0XDF,0XDF,0XDF,0XDF,0XDF,0XDF}, //Z {0x00, 0x1f, 0x11, 0x11, 0x00}, // {0x10, 0x08, 0x04, 0x02, 0x01}, // {0x00, 0x11, 0x11, 0x1f, 0x00}, // {0x04, 0x08, 0x10, 0x08, 0x04}, // {0x01, 0x01, 0x01, 0x01, 0x01}, // {0x00, 0x00, 0x10, 0x08, 0x00}, // {0x12, 0x15, 0x15, 0x15, 0x0f}, //a {0x1f, 0x09, 0x09, 0x09, 0x06}, //b {0x0e, 0x11, 0x11, 0x11, 0x0a}, //c {0x06, 0x09, 0x09, 0x09, 0x1f}, //d {0x0e, 0x15, 0x15, 0x15, 0x0d}, //e {0x0f, 0x14, 0x14, 0x10, 0x10}, //f {0x09, 0x15, 0x15, 0x15, 0x0e}, //g {0x1f, 0x08, 0x08, 0x08, 0x07}, //h {0x00, 0x00, 0x17, 0x00, 0x00}, //i {0x01, 0x01, 0x01, 0x01, 0x1e}, //j {0x1f, 0x04, 0x04, 0x0a, 0x11}, //k {0x1e, 0x01, 0x01, 0x01, 0x01}, //l {0x0f, 0x10, 0x0f, 0x10, 0x0f}, //m {0x1f, 0x10, 0x10, 0x10, 0x0f}, //n {0x0e, 0x11, 0x11, 0x11, 0x0e}, //o {0x1f, 0x12, 0x12, 0x12, 0x0c}, //p {0x0c, 0x12, 0x12, 0x12, 0x1f}, //q {0x1f, 0x08, 0x10, 0x10, 0x08}, //r {0x09, 0x15, 0x15, 0x15, 0x12}, //s {0x1e, 0x09, 0x09, 0x01, 0x02}, //t {0x1e, 0x01, 0x01, 0x02, 0x1f}, //u {0x18, 0x06, 0x01, 0x06, 0x18}, //v {0x1e, 0x01, 0x1e, 0x01, 0x1e}, //w {0x1b, 0x04, 0x04, 0x04, 0x1b}, //x {0x19, 0x05, 0x05, 0x05, 0x1e}, //y {0x11, 0x13, 0x15, 0x19, 0x11}, //z {0x00, 0x04, 0x0e, 0x11, 0x00}, // {0x00, 0x00, 0x1f, 0x00, 0x00}, // {0x00, 0x11, 0x0e, 0x04, 0x00}, // {0x08, 0x10, 0x08, 0x04, 0x08}, // {0x00, 0x00, 0x00, 0x00, 0x00} // }; unsigned char column[41]= {0 }; //display memory, cleared before used. void delayms(unsigned int ms) //just about 1ms { unsigned int n; unsigned int i; for (n=0; n8) index=1; //column tmp1=rowtable[index]; for (i=1; i<41; i++) { Cdata=!(column[i] & tmp1); Cclock=0; Cclock=1; } //row Clatch=0; Clatch=1; switch (index) { case 1: Row1=0; break; case 2: Row2=0; break; case 3: Row3=0; break; case 4: Row4=0; break; case 5: Row5=0; break; case 6: Row6=0; break; case 7: Row7=0; break; case 8: Row8=0; break; } ET0=1; } void LED_put_byte(unsigned int inp) { unsigned char i; for (i=1;i<41;i++) column[i]=column[i+1]; column[40]=inp; } void LED_puts(unsigned char *lcd_string) { unsigned char i,tmp_chr; while (*lcd_string) { tmp_chr=*lcd_string; for (i=0;i<6;i++) { LED_put_byte(font[tmp_chr-32][i]); delayms(shift_delay); } LED_put_byte(0); //space between character delayms(shift_delay); lcd_string++; } } void main() { unsigned char m[40], i; TMOD=0x20; // Timer 1, mode-2 (8-bit auto reload) TH1=0xFA; //9600 baud rate SCON=0x50; TR1=1; //start timer 1 /* read 10 bytes or till enter key */ for (i = 0; i < 240; i++) { while (RI == 0); //wait to receive data if (SBUF == '\r') break; m[i] = SBUF; // save value of data RI = 0; } m[i] = '\0'; init_timer(); shift_delay=50; //bigger = slower shift while(1) { // display m LED_puts(m); } }
and the attempt does not work on arm
#include <lpc213x.h>#include <stdio.h>
unsigned int shift_delay;const unsigned char font[96][16] ={ /* character 0x0020 (' '): (width=7, offset=0) */{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
/* character 0x0021 ('!'): (width=8, offset=14) */{0XFF,0XE,0X78,0X78,0XE0,0XFF},
/* character 0x0022 ('"'): (width=8, offset=30) */{0x00, 0xE0, 0xE0, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
/* character 0x0023 ('#'): (width=8, offset=46) */{0x00, 0x22, 0xFF, 0xFF, 0x22, 0xFF, 0xFF, 0x22, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x80, 0x00},
/* character 0x0024 ('$'): (width=8, offset=62) */0x00, 0x61, 0xF1, 0x98, 0x8C, 0xC7, 0x43, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00,
/* character 0x0025 ('%'): (width=8, offset=78) */{0xC0, 0xE3, 0x26, 0xED, 0xDB, 0x32, 0x63, 0x01, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x80},
/* character 0x0026 ('&'): (width=8, offset=94) */{0x00, 0x6F, 0xFF, 0x90, 0xF4, 0x67, 0x07, 0x04, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80},
/* character 0x0027 ('''): (width=8, offset=110) */{0x00, 0x00, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x03, 0x0F, 0x1C, 0x10, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x1C, 0x04, 0x00, 0x00},
/* character 0x0029 (')'): (width=8, offset=0) */{0x00, 0x00, 0x10, 0x1C, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x1C, 0xF8, 0xE0, 0x00, 0x00},
/* character 0x002A ('*'): (width=8, offset=16) */{0x00, 0x01, 0x05, 0x07, 0x03, 0x07, 0x05, 0x01, 0x00, 0x00, 0x40, 0xC0, 0x80, 0xC0, 0x40, 0x00},
/* character 0x002B ('+'): (width=8, offset=32) */{0x00, 0x01, 0x01, 0x07, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0x00},
/* character 0x002C (','): (width=8, offset=48) */{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x3C, 0x38, 0x00, 0x00},
/* character 0x002D ('-'): (width=8, offset=64) */{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
/* character 0x002E ('.'): (width=8, offset=80) */{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x00, 0x00},
/* character 0x002F ('/'): (width=8, offset=96) */{0x00, 0x00, 0x00, 0x01, 0x07, 0x1E, 0x18, 0x00, 0x00, 0x18, 0x78, 0xE0, 0x80, 0x00, 0x00, 0x00},
/* character 0x0030 ('0'): (width=8, offset=112) */{0x00, 0x00, 0x0F, 0x1F, 0x10, 0x16, 0x1F, 0x0F, 0x00, 0x00, 0xE0, 0xF0, 0xD0, 0x10, 0xF0, 0xE0},
/* character 0x0031 ('1'): (width=8, offset=128) */{0x00, 0x04, 0x04, 0x0C, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00},
/* character 0x0032 ('2'): (width=8, offset=144) */{0x00, 0x0C, 0x1C, 0x10, 0x11, 0x1F, 0x0E, 0x00, 0x00, 0x30, 0x70, 0xD0, 0x90, 0x10, 0x10, 0x00},
/* character 0x0033 ('3'): (width=8, offset=160) */{0x00, 0x0C, 0x1C, 0x11, 0x11, 0x1F, 0x0E, 0x00, 0x00, 0x60, 0x70, 0x10, 0x10, 0xF0, 0xE0, 0x00},
/* character 0x0034 ('4'): (width=8, offset=176) */{0x00, 0x00, 0x1F, 0x1F, 0x00, 0x07, 0x07, 0x00, 0x00, 0xC0, 0xC0, 0x40, 0x40, 0xF0, 0xF0, 0x40},
/* character 0x0035 ('5'): (width=8, offset=192) */{0x00, 0x1F, 0x1F, 0x11, 0x11, 0x11, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x30, 0xE0, 0xC0, 0x00},
/* character 0x0036 ('6'): (width=8, offset=208) */{0x00, 0x03, 0x07, 0x1E, 0x1A, 0x13, 0x01, 0x00, 0x00, 0xE0, 0xF0, 0x10, 0x10, 0xF0, 0xE0, 0x00},
/* character 0x0037 ('7'): (width=8, offset=224) */{0x00, 0x10, 0x10, 0x11, 0x17, 0x1E, 0x18, 0x00, 0x00, 0x00, 0x70, 0xF0, 0x80, 0x00, 0x00, 0x00}, /* character 0x0038 ('8'): (width=8, offset=0) */{0x00, 0x0E, 0x1F, 0x13, 0x11, 0x1F, 0x0E, 0x00, 0x00, 0xE0, 0xF0, 0x10, 0x90, 0xF0, 0xE0, 0x00},
/* character 0x0039 ('9'): (width=8, offset=16) */{0x00, 0x0F, 0x1F, 0x10, 0x10, 0x1F, 0x0F, 0x00, 0x00, 0x00, 0x90, 0xB0, 0xF0, 0xC0, 0x80, 0x00},
/* character 0x003A (':'): (width=8, offset=32) */{0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x00, 0x00},
/* character 0x003B (';'): (width=8, offset=48) */{0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x3C, 0x38, 0x00, 0x00},
/* character 0x003C ('<'): (width=8, offset=64) */{0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x10, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x10, 0x00},
/* character 0x003D ('='): (width=8, offset=80) */{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00},
/* character 0x003E ('>'): (width=8, offset=96) */{0x00, 0x10, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00, 0x10, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00},
/* character 0x003F ('?'): (width=8, offset=112) */{0x00, 0x0C, 0x1C, 0x11, 0x13, 0x1E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xB0, 0x00, 0x00, 0x00},
/* character 0x0040 ('@'): (width=8, offset=128) */{0x0F, 0x1F, 0x10, 0x11, 0x13, 0x12, 0x1F, 0x0F, 0xE0, 0xF0, 0x10, 0x90, 0xD0, 0x50, 0xD0, 0xD0},
/* character 0x0041 ('A'): (width=8, offset=144) */{0x7F, 0xFF, 0x88, 0x88, 0xFF, 0x7F},
/* character 0x0042 ('B'): (width=8, offset=160) */{0xFF, 0xFF, 0x81, 0x99, 0xDB, 0x7E},
/* character 0x0043 ('C'): (width=8, offset=176) */{0xFF, 0xFF, 0x81, 0x81, 0xC3, 0xC3},
/* character 0x0044 ('D'): (width=8, offset=192) */{0xFF, 0xFF, 0xC3, 0xC3, 0x7E, 0x3C},
/* character 0x0045 ('E'): (width=8, offset=208) */{0xFF, 0xFF, 0xDB, 0xDB, 0xDB, 0xC3},
/* character 0x0046 ('F'): (width=8, offset=224) */{0xFF, 0xFF, 0x88, 0x88, 0x88, 0x80},
/* character 0x0047 ('G'): (width=8, offset=240) */{0x7E, 0xFF, 0x81, 0x89, 0xEF, 0x6F},
/* character 0x0048 ('H'): (width=8, offset=256) */{0xFF, 0xFF, 0x08, 0x08, 0xFF, 0xFF},
/* character 0x0049 ('I'): (width=8, offset=272) */{0xC3, 0xC3, 0xFF, 0xFF, 0xC3, 0xC3},
/* character 0x004A ('J'): (width=8, offset=288) */{0x06, 0x07, 0x01, 0x01, 0xFF, 0xFE},
/* character 0x004B ('K'): (width=8, offset=304) */{0xFF, 0xFF, 0x18, 0x3C, 0x66, 0xC3},
/* character 0x004C ('L'): (width=8, offset=320) */{0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03},
/* character 0x004D ('M'): (width=8, offset=336) */{0XFF,0XE0,0X78,0X78,0XE0,0XFF},
/* character 0x004E ('N'): (width=8, offset=352) */{0xFF, 0xFF, 0x38, 0x1C, 0xFF, 0xFF}, /* character 0x004F ('O'): (width=8, offset=0) */{0x7E, 0xFF, 0x81, 0x81, 0xFF, 0x7E},
/* character 0x0050 ('P'): (width=8, offset=16) */{0xFF, 0xFF, 0xD8, 0xD8, 0xF8, 0xF8},
/* character 0x0051 ('Q'): (width=8, offset=32) */{0x7E, 0xC3, 0x81, 0x85, 0xC2, 0x7D},
/* character 0x0052 ('R'): (width=8, offset=48) */{0xFF, 0xFF, 0x88, 0x8C, 0xFF, 0x73},
/* character 0x0053 ('S'): (width=8, offset=64) */{0x72, 0xF3, 0xDB, 0xDB, 0xCF, 0x46},
/* character 0x0054 ('T'): (width=8, offset=80) */{0xC0, 0xC0, 0xFF, 0xFF, 0xC0, 0xC0},
/* character 0x0055 ('U'): (width=8, offset=96) */{0xFE, 0xFF, 0x01, 0x01, 0xFF, 0xFE},
/* character 0x0056 ('V'): (width=8, offset=112) */{0xF8, 0xFE, 0x07, 0x07, 0xFE, 0xF8},
/* character 0x0057 ('W'): (width=8, offset=128) */{0xFF, 0x03, 0x3C, 0x3C, 0x03, 0xFF}, {0x11, 0x0a, 0x04, 0x0a, 0x11}, //X {0xC0, 0x60, 0x1F, 0x1F, 0x60, 0xC0}, //Y {0XDF,0XDF,0XDF,0XDF,0XDF,0XDF}, //Z {0x00, 0x1f, 0x11, 0x11, 0x00}, // {0x10, 0x08, 0x04, 0x02, 0x01}, // {0x00, 0x11, 0x11, 0x1f, 0x00}, // {0x04, 0x08, 0x10, 0x08, 0x04}, // {0x01, 0x01, 0x01, 0x01, 0x01}, // {0x00, 0x00, 0x10, 0x08, 0x00}, // {0x12, 0x15, 0x15, 0x15, 0x0f}, //a {0x1f, 0x09, 0x09, 0x09, 0x06}, //b {0x0e, 0x11, 0x11, 0x11, 0x0a}, //c {0x06, 0x09, 0x09, 0x09, 0x1f}, //d {0x0e, 0x15, 0x15, 0x15, 0x0d}, //e {0x0f, 0x14, 0x14, 0x10, 0x10}, //f {0x09, 0x15, 0x15, 0x15, 0x0e}, //g {0x1f, 0x08, 0x08, 0x08, 0x07}, //h {0x00, 0x00, 0x17, 0x00, 0x00}, //i {0x01, 0x01, 0x01, 0x01, 0x1e}, //j {0x1f, 0x04, 0x04, 0x0a, 0x11}, //k {0x1e, 0x01, 0x01, 0x01, 0x01}, //l {0x0f, 0x10, 0x0f, 0x10, 0x0f}, //m {0x1f, 0x10, 0x10, 0x10, 0x0f}, //n {0x0e, 0x11, 0x11, 0x11, 0x0e}, //o {0x1f, 0x12, 0x12, 0x12, 0x0c}, //p {0x0c, 0x12, 0x12, 0x12, 0x1f}, //q {0x1f, 0x08, 0x10, 0x10, 0x08}, //r {0x09, 0x15, 0x15, 0x15, 0x12}, //s {0x1e, 0x09, 0x09, 0x01, 0x02}, //t {0x1e, 0x01, 0x01, 0x02, 0x1f}, //u {0x18, 0x06, 0x01, 0x06, 0x18}, //v {0x1e, 0x01, 0x1e, 0x01, 0x1e}, //w {0x1b, 0x04, 0x04, 0x04, 0x1b}, //x {0x19, 0x05, 0x05, 0x05, 0x1e}, //y {0x11, 0x13, 0x15, 0x19, 0x11}, //z {0x00, 0x04, 0x0e, 0x11, 0x00}, // {0x00, 0x00, 0x1f, 0x00, 0x00}, // {0x00, 0x11, 0x0e, 0x04, 0x00}, // {0x08, 0x10, 0x08, 0x04, 0x08}, // {0x00, 0x00, 0x00, 0x00, 0x00} //};unsigned char column[41]={ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //display memory, cleared before used.void delayms(unsigned int ms) //just about 1ms{ unsigned int n; unsigned int i; for (n=0; n<ms; n++) { for (i=0; i<100; i++); }}
void init_timer(void)
{ __irq void Timer0_IRQ(void);
IODIR0=(1 << 3) | (1 << 4)| (1 << 5)| (1 << 6)| (1 << 7)| (1 << 8)| (1 << 9)| (1 << 10)| (1 << 1)| (1 << 0); IODIR1|=(1 << 16);T0PR = 0x00000000;T0MR0 = 375000L;T0MCR = 3;T0TC = 0x00;T0TCR = 0x00000001;VICVectAddr4 = (unsigned)Timer0_IRQ;VICVectCntl4 = (0x20 | 4);VICIntEnable = (1 << 4);
}__irq void Timer0_IRQ(void)
{
unsigned int index;unsigned int i,tmp1;const unsigned char rowtable[]={0,1,2,4,8,16,32,64,128}; IOSET0|= (1 << 3) | (1 << 4)| (1 << 5)| (1 << 6)| (1 << 7)| (1 << 8)| (1 << 9)| (1 << 10);index++;if (index>8) index=1;tmp1=rowtable[index]; for (i=1; i<41; i++)
{ IOPIN1=!(column[i] & tmp1);
IOCLR0=(1 << 0);IOSET0=(1 << 0);} IOCLR0=(1 << 1);IOSET0=(1 << 1);switch (index) {case 1: IOPIN0&=(1 << 10);break; case 2: IOPIN0&=(1 << 9);break; case 3: IOPIN0=(1 << 8);break; case 4: IOPIN0=(1 << 7);break; case 5: IOPIN0=(1 << 6); break;case 6: IOPIN0=(1 << 5);break; case 7: IOPIN0=(1 << 4);break; case 8: IOPIN0=(1 << 3);break;T0IR = (1UL<<0); VICIntEnable = 0X00;} }
void LED_put_byte(unsigned int inp){ unsigned char i; for (i=1;i<41;i++)column[i]=column[i+1];column[40]=inp;} void LED_puts(char *lcd_string){unsigned char i,tmp_chr;while (*lcd_string){tmp_chr=*lcd_string;for (i=0;i<6;i++) { LED_put_byte(font[tmp_chr-32][i]); delayms(shift_delay);} LED_put_byte(0);delayms(shift_delay);lcd_string++; }}int main(){
init_timer(); shift_delay=100;{ LED_puts("8x32 Matrix LED: AT89C2051, 74HC595");} }
Hi Berto,
Thanks for your question (though I'm not sure you needed to paste _all_ the code in!).
You might find this document useful from the ARM Information Center: ARM Information Center
It covers a lot of they issues involved in migrating from 8051 to Cortex-M microcontrollers. I think a lot of the issues you will encounter in your code relate to the way in which 8051 allows you to address individual bits in I/O ports by name. While Cortex-M microcontrollers don't support this in the same way, it's relatively easy to implement using either bitmasks or bit-banding (if your particular microcontroller supports it).
Hope you find it useful.
Chris
I believe there is no straight forward answer for you question. It will take a certain degree of changes involved in the same. Still it won't be complex process to do that since the logic involves the same.