本帖最后由 dy624 于 2012-4-8 18:45 编辑
未命名.jpg (181.57 KB, 下载次数: 0)
下载附件
2012-4-8 18:39 上传
Warning [1258] D:ProjectProgramO2_POLED.c; 15. possible stack overflow when calling function "_Write_Command"
Warning [1258] D:ProjectProgramO2_POLED.c; 15. possible stack overflow when calling function "i1_Write_Command"
单片机是PIC16F877A,用普通IO模拟SPI串行通信
//OLED引脚设置
#define DC RB6
#define CS RB7
#define WR RC0
#define RD RC1
#define RES RC2
#define SCLK RD0
#define SDIN RD1
void Write_Command(uchar com)
{
uchar i;
uchar t;
//PORTB=PORTB&0x7F;
//PORTB=PORTB&0xBE;
CS =0;
DC =0;
for( i=0;i<8;i++)
{
SCLK =0;
SDIN =(bit)((com&0x80)>>7);
com =com<<1;
SCLK =1;
}
//PORTB=PORTB|0x40;
//PORTB=PORTB|0x80;
DC =1;
CS =1;
}
void Write_Data(uchar Data)
{
uchar i;
//PORTB=PORTB&0x7F;
//PORTB=PORTB|0x40;
CS =0;
DC =1;
for( i=0;i<8;i++)
{
SCLK =0;
SDIN =(bit)((Data&0x80)>>7);
Data =Data<<1;
SCLK =1;
}
//PORTB=PORTB|0x40;
//PORTB=PORTB|0x80;
DC =1;
CS =1;
}
一周热门 更多>