最后算是搞定12232单片机驱动了
时间:11-29
来源:互联网
点击:
还是那个89C52和12232的组合。但是这个12232没有Datasheet。最后我还是靠自己的分析能力和对卖家资料那么一点点的信任(现在看来是错误的)搞定(?)了这个的驱动。
现在我一直找不到方法让这个玩意显示下半屏。现在上半屏显示什么,下半屏就跟着显示。我晕……
不过至少靠前面两个程序的帮助显示出了可以辨认的字符。
不过说道这个倒让我说一下,我的P0口上的上拉电阻貌似挂掉了,结果导致我显示汉字老是掉笔画,很奇怪,尝试了用NE555/4046产生的时钟信号驱动CLK端均未成功。结果加上上拉电阻就好了。
这个是上次的驱动http://www.51hei.com/mcu/1560.html 效果好像更好些了
上显示效果图:
上程序(还是3/4成品,我得看看怎么着让下半屏亮起来):
完整的源代码下载:http://www.51hei.com/f/12232de.rar
/*------*FILE main.c* 测试驱动12232*/#include #include//#define DEBUG#ifdef DEBUG#include #endif/*-----DEVICE IO Pin map.* NMTB-S000389FGHSAY-A* 死马当活马医吧!!!* 时序68 series *///仿二进制赋值#define HEX__(n) 0x##n##UL#define B8__(x) ( (x & 0x0000000FUL) ? 1:0 )+( (x & 0x000000F0UL) ? 2:0 )+( (x & 0x00000F00UL) ? 4:0 )+( (x & 0x0000F000UL) ? 8:0 )+( (x & 0x000F0000UL) ? 16:0 )+( (x & 0x00F00000UL) ? 32:0 )+( (x & 0x0F000000UL) ? 64:0 )+( (x & 0xF0000000UL) ? 128:0 )#define B8(x) ((unsigned char)B8__(HEX__(x)))#define B16(x_msb,x_lsb) (((unsigned int)B8(x_msb)<8) + B8(x_lsb))#define B32(x_msb,x_2,x_3,x_lsb) (((unsigned long)B8(x_msb)<24) + ((unsigned long)B8(x_2)<16) + ((unsigned long)B8(x_3)<8) + B8(x_lsb))#define TH 0xFE#define TL 0x40//2K定时器值#define LCD_RESET 0xE2 //复位 #define LCD_DISPLAY_ON 0xAF //显示开 #define LCD_DISPLAY_OFF 0xAE //显示关 #define LCD_PS_ON 0xA5 //节电驱动 #define LCD_PS_OFF 0xA4 //正常驱动 #define LCD_DUTY16 0xA8 //占空比1/16 #define LCD_DUTY32 0xA9 //占空比1/32 #define LCD_END 0xEE #define LCD_RWMODE 0xE0 #define LCD_LINE0 0xC0 //开始行 #define LCD_PAGE0 0xB8 //开始页 #define LCD_COLUMN0 0x00 //开始列 #define Both_Write_Cmd(cmd) LCD_Write(0,0,cmd);LCD_Write(1,0,cmd)#define Both_Write_Data(dat) LCD_Write(0,1,dat);LCD_Write(1,1,dat)#define CLK P1_3#define RESET P1_6#define A0 P1_0#define E1 P1_2#define E2 P1_1#define LCD_RD P1_4 #define LCD_WR P1_5 #define DATA P0//渣字库,从16x8转到8x8unsigned char __code ASCII[][8]={{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},{0x0,0x0,0xE,0xFF,0xFF,0xE,0x0,0x0},{0x0,0x3,0x7,0x0,0x0,0x7,0x3,0x0},{0x8,0xFE,0xFE,0x8,0xFE,0xFE,0x8,0x0},{0xE,0x9F,0x91,0x91,0x91,0xF3,0x66,0x0},{0x8C,0xC,0x40,0x60,0x30,0x98,0x8C,0x0},{0x60,0xF6,0x9F,0xB9,0x6F,0xF6,0x90,0x0},{0x0,0x4,0x7,0x3,0x0,0x0,0x0,0x0},{0x0,0x0,0x7C,0x7E,0x83,0x81,0x0,0x0},{0x0,0x0,0x81,0x83,0x7E,0x7C,0x0,0x0},{0x20,0x28,0x78,0x70,0x70,0x78,0x28,0x20},{0x0,0x20,0x20,0x78,0x78,0x20,0x20,0x0},{0x0,0x0,0x0,0x80,0x80,0x0,0x0,0x0},{0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0},{0x0,0x0,0x0,0x80,0x80,0x0,0x0,0x0},{0x80,0x0,0x40,0x60,0x30,0x18,0xC,0x0},{0x7C,0x7E,0x83,0xB1,0x83,0x7E,0x7C,0x0},{0x0,0x84,0x86,0xFF,0xFF,0x80,0x80,0x0},{0x82,0xC3,0xE1,0xB1,0x99,0x8F,0x86,0x0},{0x2,0x83,0x91,0x91,0x91,0xFF,0x6E,0x0},{0x30,0x38,0x2C,0xA6,0xFF,0xFF,0xA0,0x0},{0x1F,0x9F,0x91,0x91,0x91,0xF1,0x61,0x0},{0x7C,0xFE,0x93,0x91,0x91,0xF0,0x60,0x0},{0x3,0x3,0xC1,0xE1,0x31,0x1F,0xF,0x0},{0x6E,0xFF,0x91,0x91,0x91,0xFF,0x6E,0x0},{0xE,0x9F,0x91,0x91,0x91,0x7F,0x7E,0x0},{0x0,0x0,0x0,0xC,0xC,0x0,0x0,0x0},{0x0,0x0,0x80,0x8C,0xC,0x0,0x0,0x0},{0x0,0x20,0x70,0x58,0xC,0x86,0x82,0x0},{0x0,0x48,0x48,0x48,0x48,0x48,0x48,0x0},{0x0,0x82,0x86,0xC,0x58,0x70,0x20,0x0},{0x6,0x7,0x1,0xF1,0xF9,0xF,0x6,0x0},{0x7C,0xFE,0x82,0xF2,0xF2,0xFE,0x7C,0x0},{0xF8,0xFC,0x26,0x23,0x26,0xFC,0xF8,0x0},{0x81,0xFF,0xFF,0x91,0x91,0xFF,0x6E,0x0},{0x7C,0x7E,0x83,0x81,0x81,0x83,0x6,0x0},{0x81,0xFF,0xFF,0x81,0x83,0x7E,0x7C,0x0},{0x81,0xFF,0xFF,0x91,0xB9,0x83,0x87,0x0},{0x81,0xFF,0xFF,0x91,0x39,0x3,0x7,0x0},{0x7C,0x7E,0x83,0xA1,0xA1,0x63,0xE6,0x0},{0xFF,0xFF,0x10,0x10,0x10,0xFF,0xFF,0x0},{0x0,0x0,0x81,0xFF,0xFF,0x81,0x0,0x0},{0x40,0xC0,0x80,0x81,0xFF,0x7F,0x1,0x0},{0x81,0xFF,0xFF,0x30,0x78,0xCF,0x87,0x0},{0x81,0xFF,0xFF,0x81,0x80,0x80,0x80,0x0},{0xFF,0xFF,0xE,0x1C,0xE,0xFF,0xFF,0x0},{0xFF,0xFF,0xE,0x1C,0x38,0xFF,0xFF,0x0},{0x7E,0xFF,0x81,0x81,0x81,0xFF,0x7E,0x0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0x80,0x0,0x0},{0xF8,0xF8,0x18,0x70,0x18,0xF8,0xF0,0x0},{0x8,0xF8,0xF0,0x8,0x8,0xF8,0xF0,0x0},{0x70,0xF8,0x88,0x88,0x88,0xF8,0x70,0x0},{0x8,0xF8,0xF0,0x88,0x88,0xF8,0x70,0x0},{0x70,0xF8,0x88,0x88,0xF0,0xF8,0x8,0x0},{0x88,0xF8,0xF0,0x98,0x8,0x38,0x30,0x0},{0x10,0xB8,0xE8,0xC8,0xC8,0x98,0x10,0x0},{0x8,0x8,0x7E,0xFF,0x88,0x88,0x0,0x0},{0x78,0xF8,0x80,0x80,0x78,0xF8,0x80,0x0},{0x0,0x78,0x78,0x80,0x80,0x78,0x78,0x0},{0x78,0xF8,0x80,0x60,0x80,0xF8,0x78,0x0},{0x88,0x98,0x70,0x60,0x70,0x98,0x88,0x0},{0x78,0xF8,0x80,0x80,0x80,0xF8,0xF8,0x0},{0x98,0x98,0xC8,0xE8,0xB8,0x98,0x88,0x0},{0x0,0x10,0x10,0x7E,0xEF,0x81,0x81,0x0},{0x0,0x0,0x0,0xEF,0xEF,0x0,0x0,0x0},{0x0,0x81,0x81,0xEF,0x7E,0x10,0x10,0x0},{0x2,0x3,0x1,0x3,0x2,0x3,0x1,0x0}};/*---------------------生成的以下字的字库:驱动编写万致远字库由万致远HZK软件建立。使用点阵显示模式HZ就是您需要的汉字库----------------*/unsigned char __code HZ[][32]={/******点阵*******0000100000000100111111011111111000001001000000000100100101000100010010010100010001001001001010000100100100101000010010010001000001111101000100000000010100101000000001010010100000011101010001001110010110000100010001010000000000010101111111100000100000000000*******点阵结束********/{0x2,0xFA,0x2,0x2,0xFF,0x2,0x0,0xFE,0x2,0x1A,0x62,0x82,0x62,0x1B,0x2,0x0,0x10,0x31,0x11,0x49,0x89,0x7F,0x0,0x7F,0x50,0x48,0x46,0x41,0x46,0x58,0x40,0x0},/******点阵*******0000000001000000000010000100000001111100010000000000000001000100000001011111111011111110010001000001000001000100000100000100010000100000010001000010010001000100010000101000010011111110100001000100000100000100000000010000010000000010001010000000010000010000*******点阵结束********/{0x20,0x24,0x24,0xE4,0x26,0x34,0x20,0x10,0x10,0xFF,0x10,0x10,0x10,0xF8,0x10,0x0,0x8,0x1C,0xB,0x8,0x8,0x8A,0x4C,0x30,0xC,0x3,0x40,0x80,0x40,0x3F,0x0,0x0},/******点阵*******0001000010000000000100000100100000100011111111000010001000001000010010100000100011111011111110000001001000000000001000100000010001000011111111101111011010010100010010101001010000000011111111000001101010010100111000101001010001000010100101000000001000001100*******点阵结束********/{0x20,0x30,0xAC,0x63,0x30,0x0,0xFC,0x24,0x25,0x26,0x24,0x24,0x3E,0x84,0x0,0x0,0x22,0x67,0x22,0x12,0x14,0x2,0xFF,0x9,0x7F,0x9,0x9,0x7F,0x89,0xFF,0x1,0x0},/******点阵*******0000000000000000011111111111111001000000000000101000100000000100000010000010000000001111111100000000100000000000000010000000100000001111111111000000000000001000000000000100100001111111111010000000000000001000000000000000100000000000010100000000000000100000*******点阵结束********/{0x8,0x6,0x2,0x2,0xFA,0x22,0x22,0x22,0x22,0x22,0x32,0x22,0x82,0xA,0x6,0x0,0x0,0x8,0x8,0x8,0x9,0x9,0x9,0x9,0x9,0x4D,0x89,0x41,0x3F,0x1,0x0,0x0},/******点阵*******0000000000000000000000000000010011111111111111100000001000000000000000100000000000000010000100000000001111111000000000100001000000000010000100000000010000010000000001000001000000000100000100000000100000010000000100000001000000100000101000000100000001000000*******点阵结束********/{0x4,0x4,0x4,0x4,0x4,0x4,0xFC,0x44,0x44,0x44,0x44,0xE4,0x44,0x6,0x4,0x0,0x0,0x80,0x40,0x20,0x10,0xE,0x1,0x0,0x40,0x80,0x40,0x3F,0x0,0x0,0x0,0x0},/******点阵*******0000010001000000111111100100000000010000010000000001000001000100001000001111111001000101000010001111111010001000000100001000100000010000100010000111110010010000000100000101000000010000001000000001111001010000111100001000100001000001000011100000011000000100*******点阵结束********/{0x42,0x62,0x52,0xCE,0x42,0x63,0x42,0x20,0xD0,0x1F,0x10,0x10,0xF0,0x18,0x10,0x0,0x20,0x62,0x22,0x3F,0x12,0x92,0x90,0x40,0x23,0x14,0x8,0x16,0x61,0xC0,0x40,0x0},/******点阵*******0000000000010000010000111111100000110000000000000001000000000000000000000000100000000111111111001111000100100000000100010010000000010001001000000001000100100100000100100010010000010010000111000001010000000000001010000000011001000111111111000000000000000000*******点阵结束********/{0x40,0x42,0x44,0xCC,0x0,0x20,0x22,0xE2,0x22,0x22,0xE2,0x23,0x32,0x20,0x0,0x0,0x0,0x40,0x20,0x1F,0x20,0x50,0x4C,0x43,0x40,0x40,0x47,0x48,0x48,0x6E,0x20,0x0}};void OutCLK() __interrupt 1 __using 1//CLK out 2kHz{TF0=0;//CLRTR0=0;EA=0;TH0=TH;TL0=TL;CLK=!CLK;TR0=1;EA=1;}void Delay_ms(UINT x){UINT y;while(x--){for(y=0;y<600;y++);}}void Init_Timer(){TMOD=0x21;//T0计数器模式,T1八位重载模式TH0=TH;TL0=TL;TR0=1;ET0=1;SCON = 0x50;TH1 = 0xFF; //57600TL1 = 0xFF; TR1 = 1;PCON=PCON|0x80;//波特率加倍EA=1;}void putchar(char s){SBUF=s;while(!TI);TI=0;}BYTE Read_Status(BOOL right){BYTE tData;DATA=0xff;LCD_WR=1;LCD_RD=0;A0=0;if(right){E1=0;}else{E2=0;}tData=DATA;if(right){E1=1;}else{E2=1;}LCD_RD=1;A0=1;return tData;}void LCD_Write(BOOL right,BOOL disp,BYTE Data){//模拟8080/*BYTE rTemp=0xff;while(rTemp & 0x7F){rTemp=Read_Status(right);}*/if(right){E1=0;}else{E2=0;}A0=disp;//disp=1数据,disp=0显示DATA=Data;LCD_RD=1;LCD_WR=0;__asmNOPNOPNOPNOP__endasm;LCD_WR=1;if(right){E1=1;}else{E2=1;}__asmNOPNOPNOPNOPNOPNOPNOPNOPNOPNOP__endasm;}BYTE LCD_Read(BOOL right){//模拟8080BYTE tData;if(right){E1=0;}else{E2=0;}DATA=0xFF;LCD_WR=1;LCD_RD=0;tData=DATA;LCD_RD=1;if(right){E1=1;}else{E2=1;}return tData;}void SetPage(BYTE page0,BYTE page1){LCD_Write(0,0,0xB8|page1);LCD_Write(1,0,0xB8|page0);}void SetAddress(BYTE address0,BYTE address1){LCD_Write(0,0,address1);LCD_Write(1,0,address0);}void LCD_Cls(BYTE FILL){BYTE i;BYTE page;for (page=0;page<4;page++){SetPage(page,page);SetAddress(0,0);for (i=0;i<61;i++){Both_Write_Data(FILL);}}}void Init_LCD(){RESET=1;RESET=0;//8080时序#ifdef DEBUGprintf("Status(Chip1):0x%X",Read_Status(0));printf("Status(Chip2):0x%X",Read_Status(1));#endifBoth_Write_Cmd(LCD_RESET);//软复位#ifdef DEBUGprintf("Status(Chip1):0x%X",Read_Status(0));printf("Status(Chip2):0x%X",Read_Status(1));#endifBoth_Write_Cmd(LCD_PS_OFF);//正常驱动Both_Write_Cmd(LCD_DISPLAY_ON);//开显示Both_Write_Cmd(LCD_DUTY16);//16%占空比#ifdef DEBUGprintf("Status(Chip1):0x%X",Read_Status(0));printf("Status(Chip2):0x%X",Read_Status(1));#endif}/** CODE: A0 /RD /WR D7 D6 D5 D4 D3 D2 D1 D0L L H BUSY ADC ON/OFF RESET LLLL*/void Draw8(BOOL right,BYTE Asc){BYTE i;for(i=0;i<8;i++){LCD_Write(right,1,ASCII[Asc-32][i]);}}void DrawASCIIStr(BOOL right,BYTE *str){while(*str!=){Draw8(right,*str);str++;}}void main(){ BYTE i,j;Init_Timer();//启动定时器#ifdef DEBUGprintf("System started.");#endifInit_LCD();LCD_Cls(0x00);//清屏SetPage(0,0);SetAddress(0,0);for(j=0;j<4;j++){for(i=0;i<16;i++){LCD_Write(0,1,HZ[j][i]);}}SetPage(1,1);SetAddress(0,0);for(j=0;j<4;j++){ for(i=16;i<32;i++){LCD_Write(0,1,HZ[j][i]);}}//显示“驱动编写”SetPage(0,0);SetAddress(0,0);DrawASCIIStr(1,"BY");//显示BYfor(j=4;j<7;j++){for(i=0;i<16;i++){LCD_Write(1,1,HZ[j][i]);}}SetPage(1,1);SetAddress(16,16);for(j=4;j<7;j++){ for(i=16;i<32;i++){LCD_Write(1,1,HZ[j][i]);}}//显示“万致远”while(1){//LCD_Cls(0xff);//Delay_ms(100);//LCD_Cls(0xAA);//Delay_ms(100);//LCD_Cls(0x55);//Delay_ms(100);}}
12232单片机驱 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)