本帖最后由 dccdaa2222 于 2010-12-9 14:50 编辑
我
有看到二楼说的.加上后又出现在这[样的问题???晕晕,,,,,,还有人知道是怎 么回事吗?
修改后的源码:
#include <c8051F340.h>
//#include <stdio.h>
//#include <stdlib.h>
#include "intrins.h"
#include <string.h>
void Sysclk_Init (void);
void Port_Init (void);
void Woled_Command(unsigned char command);
void Woled_Data(unsigned char dat);
#define NOP _nop_();_nop_();_nop_();_nop_()
#define Woled_DATA P1;
sbit Woled_CS =P2^3;
sbit Woled_RES =P2^2;
sbit Woled_A0 =P2^1;//SSD1303_DC//
sbit Woled_WR =P2^0;
sbit Woled_RD =P0^5;
unsigned char code matrix1[128]={ //王,32*32
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,
0x00,0x18,0x04,0x00,0x00,0x18,0x06,0x00,0x00,0x18,
0x06,0x00,0x80,0x18,0x06,0x01,0x80,0x18,0x06,0x01,
0x80,0x18,0x06,0x01,0x80,0x18,0x06,0x01,0x80,0x18,
0x06,0x01,0x80,0x18,0x06,0x01,0x80,0x18,0x06,0x01,
0x80,0x18,0x06,0x01,0x80,0x18,0x06,0x01,0x80,0x18,
0x07,0xFF,0xFF,0xF8,0x07,0xFF,0xFF,0xF8,0x07,0xFF,
0xFF,0xF8,0x06,0x01,0x80,0x18,0x06,0x01,0x80,0x18,
0x06,0x01,0x80,0x18,0x06,0x01,0x80,0x18,0x06,0x01,
0x80,0x18,0x06,0x01,0x80,0x18,0x06,0x01,0x80,0x18,
0x0E,0x03,0x80,0x18,0x0E,0x01,0x80,0x18,0x0E,0x00,
0x80,0x38,0x06,0x00,0x00,0x78,0x00,0x00,0x00,0x38,
0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00
};
unsigned char code matrix2[128]={ //利,32*32
0x00,0x00,0x00,0x00,0x00,0x10,0x00,0xC0,0x00,0x18,
0x01,0xC0,0x04,0x18,0x03,0x80,0x04,0x10,0x07,0x00,
0x0C,0x10,0x1E,0x00,0x0C,0x10,0x7C,0x00,0x0C,0x10,
0xF0,0x00,0x0C,0x17,0xE0,0x00,0x0C,0x1F,0xC0,0x00,
0x1F,0xFF,0xFF,0xFE,0x1F,0xFF,0xFF,0xFE,0x1F,0xFF,
0xFF,0xFC,0x38,0x11,0x80,0x00,0x38,0x11,0xC0,0x00,
0x78,0x10,0xF0,0x00,0x78,0x30,0xF8,0x00,0x38,0x70,
0x78,0x00,0x10,0x30,0x38,0x00,0x00,0x10,0x00,0x00,
0x07,0xFF,0xFF,0x00,0x07,0xFF,0xFF,0x18,0x03,0xFF,
0xFE,0x18,0x02,0x00,0x00,0x18,0x00,0x00,0x00,0x1C,
0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x1E,0x7F,0xFF,
0xFF,0xFE,0x7F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xF0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
unsigned char code matrix3[128]={ //明,32*32
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0xFF,0xFF,0xF8,0x3F,0xFF,0xFF,0xFC,
0x1F,0xFF,0xFF,0xFE,0x18,0x60,0x80,0x38,0x18,0x60,
0x80,0x38,0x18,0x60,0x80,0x70,0x18,0x60,0x80,0x60,
0x18,0x60,0x80,0xE0,0x18,0x60,0x80,0xC0,0x18,0x60,
0x80,0x80,0x18,0x7F,0x81,0x80,0x18,0x7F,0xE0,0x00,
0x18,0x7F,0xFC,0x00,0x18,0x60,0xFF,0x00,0x18,0x60,
0x8F,0x80,0x18,0x60,0x83,0xE0,0x18,0x60,0x81,0xE0,
0x18,0x60,0x80,0xF0,0x18,0x60,0x80,0x78,0x3F,0xF8,
0x80,0x3C,0x3F,0xF8,0x80,0x1C,0x1F,0xF0,0x80,0x1C,
0x00,0x01,0x80,0x1E,0x00,0x03,0x80,0xFE,0x00,0x01,
0x83,0xFE,0x00,0x00,0x80,0x0E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
void Delay_us(unsigned char times)
{
unsigned char i,j;
for(i=0;i<times;i++){
for(j=0;j<24;j++)
_nop_();
}
}
void System_Init (void)
{
PCA0MD &= ~0x40; // Disable Watchdog timer
PCA0MD = 0x00;
Sysclk_Init (); // initialize system clock
Port_Init (); // configure cross bar
}
void Sysclk_Init (void)
{
//24MHz
int i = 0;
CLKMUL = 0x80;
for (i = 0; i < 20; i++); // Wait 5us for initialization
CLKMUL |= 0xC0;
while ((CLKMUL & 0x20) == 0);
CLKSEL = 0x02;
OSCICN = 0x83;
}
void Port_Init()
{
XBR0 = 0x00;
XBR1 = 0xC0;
}
void Woled_init(void)
{
Woled_RES=0;
Delay_us(30);
Woled_RES=1;
Delay_us(20);
Woled_Command(0xAE); //DOT MARTIX DISPLAY OFF
Woled_Command(0x40); //SET DISPLAY START LINE(40H-7FH)
Woled_Command(0xA1); //SET SEGMENT RE-MAP(0A0H-0A1H)
Woled_Command(0xA4); //ENTIRE DISPLAY OFF(0A4H-0A5H)
Woled_Command(0xA6); //SET NORMAL DISPLAY(0A6H-0A7H)
Woled_Command(0xC8); //COM SCAN COM1-COM64(0C8H,0C0H)
Woled_Command(0xA8); //SET MULTIPLEX RATIO 64
Woled_Command(0x3F);
Woled_Command(0xD3); //SET DISPLAY OFFSET(OOH-3FH)
Woled_Command(0x00);
Woled_Command(0xD5); //SET FRAME FREQUENCY
Woled_Command(0x50); //100Hz
Woled_Command(0xD9); //SET DIS-/PRE-_CHARGE PERIOD
Woled_Command(0x23);
Woled_Command(0xDA); //COM PIN CONFIGURATION(02H,12H)
Woled_Command(0x12);
Woled_Command(0xDB); //SET VCOM DESELECT LEVEL(035H)
Woled_Command(0x35);
Woled_Command(0x81); //CONTARST CONTROL(00H-0FFH)
Woled_Command(0x4F);
Woled_Command(0xAD); //SET DC/DC BOOSTER(8AH=OFF,8BH=ON)
Woled_Command(0x8A);
Woled_Command(0xAF); //DSPLAY ON
}
void Woled_Command(unsigned char command)
{
Woled_A0=0;
_nop_();
Woled_CS=0;
_nop_();
Woled_RD=1;
Woled_WR=0;
_nop_();
Woled_DATA=command;
Delay_us(1);
Woled_WR=1;
_nop_();
Woled_CS=1;
}
void Woled_Data(unsigned char dat)
{
Woled_A0=1;
_nop_();
Woled_CS=0;
_nop_();
Woled_RD=1;
Woled_WR=0;
_nop_();
P1=dat;
_nop_();
Woled_WR=1;
_nop_();
Woled_CS=1;
}
unsigned char ByteInvert(unsigned char chSrc)
{
unsigned chDst=0;
if (chSrc & 0x80) chDst |= 0x01;
if (chSrc & 0x40) chDst |= 0x02;
if (chSrc & 0x20) chDst |= 0x04;
if (chSrc & 0x10) chDst |= 0x08;
if (chSrc & 0x08) chDst |= 0x10;
if (chSrc & 0x04) chDst |= 0x20;
if (chSrc & 0x02) chDst |= 0x40;
if (chSrc & 0x01) chDst |= 0x80;
return(chDst);
}
void Woled_Character(unsigned char x,unsigned char y,unsigned char *character)
{
unsigned char i,j;
for(i=0;i<32;i++)
{
for(j=0;j<4;j++)
{
Woled_Command(0xb0+y+j);
Woled_Command((x+i+31) & 0xf);
Woled_Command(0x10+((x+i+31)>>4));
Woled_Data(ByteInvert(*(i*4+j+character)));
}
}
}
void main(void)
{
unsigned char i;
System_Init();
Woled_init();
Woled_Character(1,1,matrix1);
Woled_Character(33,1,matrix2);
Woled_Character(65,1,matrix3);
while(1);
} |