各位好!本人在KL02下调试LCD显示屏,需要一个时钟脉冲输给LCD,然而使用LPTMR做一个定时翻转某个IO口电平作为时钟输到LCD,下面是我写的代码,遇到的问题是,我把 frameBuffer 变量全部注释调,LPTMR中断运行正常,可以把frameBuffer 变量用上,程序不能正常运行。请大侠们帮忙看看,问题出在那?
感激不尽!
LCD.C中的代码:
#include "ls013b7dh03.h"
#include "font.h"
#include "lptm.h"
#include "spi.h"
#define MAX_CHAR_POSX 122
#define MAX_CHAR_POSY 122
volatile uint8_t frameBuffer[MLCD_BUF_SIZE];
void VCOM_Init(void)
{
NVIC_SetPriority(LPTimer_IRQn,3);
Lptmr_Init(500,1);
NVIC_EnableIRQ(LPTimer_IRQn);
}
void LS013B7DH03_DelayUs(uint16_t count)
{
count = count*100;
while(count--);
}
void LS013B7DH03_Init(void)
{
init_SPI0(SPI_Master);
VCOM_Init();
CS_LO;
DISP_LO;
LS013B7DH03_DelayUs(6);
DISP_HI;
LS013B7DH03_Clear();
}
void LS013B7DH03_SendData(uint8_t data)
{
SPI0_SendData8(data);
}
//addr µØÖ·
//count ÐÐÊý
//data Êý¾ÝÖ¸Õë
void LS013B7DH03_WriteLine(uint8_t addr, uint8_t count,uint8_t *data)
{
uint8_t i;
CS_HI;
LS013B7DH03_DelayUs(6);
LS013B7DH03_SendData(MLCD_WR);
if(count<=1)
{
LS013B7DH03_SendData(addr);
for(i=0;i<MLCD_BYTES_LINE; i++)
{
LS013B7DH03_SendData(*data);
}
LS013B7DH03_SendData(0);
}
else
{
while(count--)
{
LS013B7DH03_SendData(addr++);
for(i=0;i<MLCD_BYTES_LINE; i++)
{
LS013B7DH03_SendData(*data);
data++;
}
LS013B7DH03_SendData(0);
}
}
LS013B7DH03_SendData(0);
LS013B7DH03_DelayUs(2);
CS_LO;
LS013B7DH03_DelayUs(2);
}
void LS013B7DH03_Clear(void)
{
CS_HI;
LS013B7DH03_DelayUs(6);
LS013B7DH03_SendData(MLCD_CM);
LS013B7DH03_SendData(0);
LS013B7DH03_DelayUs(2);
CS_LO;
LS013B7DH03_DelayUs(2);
}
void LS013B7DH03_WriteBuffer(volatile uint16_t x, volatile uint16_t y, volatile uint8_t data)
{
volatile uint8_t temp;
if(x>MLCD_XRES)return;
if(y>MLCD_YRES)return;
//temp = frameBuffer[MLCD_BYTES_LINE*y + x/8];
if(data)
{
temp |= 1<<((x%8));
}
else
{
temp &= ~(1<<((x%8)));
}
// frameBuffer[MLCD_BYTES_LINE*y + (x/8)] = temp;
}
void LS013B7DH03_ShowChar(volatile uint16_t x, volatile uint16_t y, volatile uint8_t mode,volatile uint8_t data)
{
volatile uint16_t i,j;
volatile uint8_t temp;
data = data-' ';
if(mode==0)
{
for(i=0;i<16;i++)
{
temp=ascii_8x16[data*16+i];
for(j=0;j<8;j++)
{
if((temp<<j)&0x80)
LS013B7DH03_WriteBuffer(x+j,y+i,0);
else
LS013B7DH03_WriteBuffer(x+j,y+i,1);
}
}
}
else
{
for(i=0;i<16;i++)
{
temp=ascii_8x16[data*16+i];
for(j=0;j<8;j++)
{
if((temp<<j)&0x80)
LS013B7DH03_WriteBuffer(x+j,y+i,1);
else
LS013B7DH03_WriteBuffer(x+j,y+i,0);
}
}
}
}
void LS013B7DH03_ShowString(volatile uint16_t x, volatile uint16_t y, volatile uint8_t mode,volatile uint8_t *data)
{
mode= !mode;
while(*data!='\0')
{
if(x>MAX_CHAR_POSX){x=0;y+=16;}
if(y>MAX_CHAR_POSY){y=x=0;}
LS013B7DH03_ShowChar(x,y,mode,*data);
x+=8;
data++;
}
}
void LS013B7DH03_ShowPic(volatile uint16_t x, volatile uint16_t y, volatile uint16_t width,volatile uint16_t height, volatile uint8_t mode,uint8_t *data)
{
volatile uint16_t i,j;
volatile uint8_t temp;
volatile uint16_t count;
volatile uint16_t xpos,ypos;
width = width/8;
count=height*width;//????
if(mode==0)
{
for(i=0;i<count;i++)
{
temp= data;
ypos=y+i/width;
xpos=(i%width)*8 + x;
for(j=0;j<8;j++)
{
if((temp<<j)&0x80)
LS013B7DH03_WriteBuffer(xpos+j,ypos,1);
else
LS013B7DH03_WriteBuffer(xpos+j,ypos,0);
}
}
}
else
{
for(i=0;i<count;i++)
{
temp= data;
ypos=y+i/width;
xpos=(i%width)*8 + x;
for(j=0;j<8;j++)
{
if((temp<<j)&0x80)
LS013B7DH03_WriteBuffer(xpos+j,ypos,0);
else
LS013B7DH03_WriteBuffer(xpos+j,ypos,1);
}
}
}
}
//¸üÐÂlcdÄÚÈÝ
void LS013B7DH03_Update(void)
{
//LS013B7DH03_WriteLine(1, 128,(uint8_t*)frameBuffer);
}
//Çå¿Õ»º³åÇøÄÚÈÝ
void LS013B7DH03_flash(void)
{
uint16_t i;
for(i=0;i<2048;i++)
{
// frameBuffer=0xff;
}
}
/***************************************** E N D *********************************************/
|