本帖最后由 milkyway1888 于 2011-5-25 15:20 编辑
把我的代码贴出来,兄弟们帮我分析一下,看看问题究竟出在哪里:
main.c
----------------------------------------
int main(ulong arc,void *argv)
{
char x=0;
// uint uiColor;
// uint i;
/* DevHandle hRS232Handle;
EA_ucOpenDevice("COM", EM_io_PORT1, &hRS232Handle);
EA_ucInitRS232(hRS232Handle, EM_232_115200BPS, EM_232_NOPAR, EM_232_8DBS);
EA_ucWriteDevice(hRS232Handle, 9, 1, "case RED\r\n");
EA_ucWriteDevice(hRS232Handle, 9, 1, "case YEL\r\n");
while(1)
{
EA_ucWriteDevice(hRS232Handle, 13, 1, "Set To High\r\n");
rPDATB|=(1<<10);
for(i=0; i<0xFFFFF; i++);
EA_ucWriteDevice(hRS232Handle, 13, 1, "Set To low \r\n");
rPDATB&=~(1<<10);
for(i=0; i<0xFFFFF; i++);
}
*/
EI_lcd_vInit0();
while(1)
{
switch(x)
{
case 0: Clear(RED); break;
case 1: Clear(BLUE); break;
case 2: Clear(YELLOW); break;
case 3: Clear(GRAY); break;
case 5: DrawHorizonLine(0,0x0001,0x00EF,0x0001, BLUE); break; //程序就卡死在这个位置
case 6: DrawHorizonLine(0,0x0002,0x00EF,0x0002, BLUE); break;
case 9: GLCD_Test();break;
}
x++;
if(x==10) x=0;
Delayms(2000);
}
return 0;
}
/****************************************************************************
* 函数名称:Delayms(uint nCount)
* 功 能:实现毫秒级的延时操作,精度为10ms
* 入口参数:nCount-毫秒数
* 出口参数:无
****************************************************************************/
void Delayms(uint nCount)
{
volatile uint i;
for (i = 0; i < 5000*nCount; i++);
}
/*******************************************************************************
* 函数名称: DrawHorizonLine
*
* 功能描述: 画横线
*
* 输入参数: uiBeginX - 起始点横坐标(0~239)
* uiBeginY - 起始点纵坐标(0~319)
* uiEndX - 终止点横坐标(0~239)
* uiEndY - 终止点纵坐标(0~319)
*
*******************************************************************************/
void DrawHorizonLine(int iBeginX, int iBeginY,int iEndX,int iEndY, ushort uiColor)
{
int curx,cury;
curx = (int)iBeginX;
cury = (int)iBeginY;
uiColor&=0xFFFF;
EI_lcd_vDrawPixel0(curx,cury,uiColor);
while(curx!=iEndX )
{
curx += 1;
EI_lcd_vDrawPixel0(curx,cury,uiColor);
}
// 更新显示
EI_lcd_vUpdateDisplay();
}
---------------------------------------
调用lcd.c
----------------------------------------
/****************************************************************************
* 函数名称:Clear(ushort Color)
* 功 能: 直接清屏函数,不使用缓冲区
***************************************************************************/
void Clear(ushort Color)
{
uint index;
SetWindows(0x0000,0x0000,0x00EF,0x013F);
SetCursor(0x0000,0x0000);
WRITE_INDEX(0x22);
for(index=0;index<76800;index++)
{
WRITE_DATA(Color);
}
}
/**********************************************************************
* 函数名称: EI_lcd_vDrawPixel0
*
* 功能描述: 将液晶上坐标点(iScrX,iScrY)的象素用uiColor填充
*
***********************************************************************/
void EI_lcd_vDrawPixel0(int iScrX, int iScrY, ushort uiColor)
{
if (iScrX >= EG_lcd_tViewPort.lLeft && iScrX <= EG_lcd_tViewPort.lRight &&
iScrY >= EG_lcd_tViewPort.lTop && iScrY <= EG_lcd_tViewPort.lBottom)
{
EG_lcd_pucCurrentDispMem[(iScrY * EM_lcd_DotsPerLine + iScrX) * EM_lcd_BytePerPixel] = (uchar)(uiColor>>8);
EG_lcd_pucCurrentDispMem[(iScrY * EM_lcd_DotsPerLine + iScrX) * EM_lcd_BytePerPixel + 1] = (uchar)(uiColor&0xff);
}
}
/*******************************************************************************
* 函数名称: EI_lcd_vUpdateDisplay
*
* 功能描述: 刷新显示
*
*******************************************************************************/
void EI_lcd_vUpdateDisplay(void)
{
DevHandle hRS232Handle;
//输出串口调试信息
EA_ucOpenDevice("COM", EM_io_PORT1, &hRS232Handle);
EA_ucInitRS232(hRS232Handle, EM_232_115200BPS, EM_232_NOPAR, EM_232_8DBS);
EA_ucWriteDevice(hRS232Handle, 16, 1, "LCD Update set!\r\n");
SetWindows(0x0000,0x0000,0x00EF,0x013F);
SetCursor(0x0000,0x0000);
WRITE_INDEX(0x22);
//连续写入SPI
LCD_RESET;
EI_spi_vSendByte(DATA_WRITE);
for (j=0; j <76800; j++)
{
EI_spi_vSendByte(EG_lcd_pucCurrentDispMem[j*2]);
EI_spi_vSendByte(EG_lcd_pucCurrentDispMem[j*2+1]);
}
LCD_SET;
EA_ucWriteDevice(hRS232Handle, 16, 1, "LCD Update end!\r\n");
EA_ucCloseDevice(&hRS232Handle);
} |