/****************************************Copyright (c)**********************************
**
**--------------file infromation----------------------------------------------------------------
** file name: startup.c
** author: leo
** data: 2013-11-20
** description: start up program
** Technical support: jewoo lighting
**
**---------- version information-------------------------------------------------------------------
** version: V1.0
** explain:
**-------------------------------------------------------------------------------------*
****************************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include"pic.h"
#include"pic16f1829.h"
#include"math.h"
#include"stdio.h"
#include"stdlib.h"
#include "startups.h"
#include"type.h"
#include <eeprom_routines.h>
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define cs1 RC0 //HT1621 select chip
#define wr RC2 //HT1621 Write clock
#define _data RC3 //HT1621 data
#define RD RC1 //HT1621 Read clock
//unsigned char seven_SEG [10] = {0xBE,0x06,0xDA,0x5E,0x66,0x7c,0xEC,0x16,0xFE,0x76};
INT8U DpyNum[6]; //显示缓冲区
/*******************************************************************************
* Function Name : sTargetInit
* Description : initialization
* Input : None
* Output : None
* Return : None
*******************************************************************************/
//寫數據高位,高位再前
void HT1621Wr_DataH(unsigned char Data,unsigned char n)
{
unsigned char i;
for(i=0;i<n;i++)
{
if(Data>=0x80) //判斷最高位
_data=1;
else
_data=0;
wr=0;
wr=1;
Data<<=1;
}
}
//寫數據低位,低位再前
void HT1621Wr_DataL(unsigned char Data,unsigned char n)
{
unsigned char i;
for(i=0;i<n;i++)
{
Data>>=1;
_data=CARRY;
wr=0;
wr=1;
}
}
/***************************************************
發送命令到HT1621
cmmand->發送命令參數
****************************************************/
void HT1621WrCommand(unsigned char cmd)
{
cs1=0;
HT1621Wr_DataH(0x80,3); //發送寫數據參數1000
HT1621Wr_DataH(cmd,9); //發送命令格式,寫入9位數據
cs1=1;
}
/***************************************************
發送一個字節數據
data->發送的數據 addr->發送的地址
****************************************************/
void Wr_1621(unsigned char addr,unsigned char dat)
{
addr<<=2;
cs1=0;
HT1621Wr_DataH(0xA0,3); //發送寫數據模式1010
HT1621Wr_DataH(addr,6); //寫入6位地址
HT1621Wr_DataL(dat,4); //寫入數據低四位
cs1=1;
}
void InitLcd(void)
{
TRISC0=0;//output pin. this pin used to lcd CS.
TRISC2=0;//output pin. this pin used to lcd WR.
TRISC3=0;//output pin. this pin used to lcd data.
HT1621WrCommand(0x01); //SYS EN
HT1621WrCommand(0x29); // //4 COM 1/3 BIAS
HT1621WrCommand(0x03); //LCD ON
}
void clear(void)
{
unsigned char i;
for(i=0;i<0x22;i++)
Wr_1621(i,0x00);
}
void full(void)
{
unsigned char i;
for(i=0;i<0X22;i++)
Wr_1621(i,0xff);
}
void delay20ms(void)
{
unsigned int i;
for (i=0;i<10000;i++);
}
/*************************************************************/
/*************************************************************/
void main(void)
{
InitLcd();
while(1)
{
full();
delay20ms();
delay20ms();
clear();
delay20ms();
delay20ms();
}
}
這程序寫完後完全不會亮,但我的版子測試過是沒問題的,我不太清楚我的程序哪有問題,有沒有人可以幫忙說一下哪裡有問題的
|