PNP-LinE

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » PNP-LinE » Контроллеры и Компьютеры. » LCD TIC5231 и PIC


LCD TIC5231 и PIC

Сообщений 1 страница 2 из 2

1

LCD TIC5231:
Драйвер ML1001.
5 цифр +1.

2

MPLAB IDE версия 7.52
mcc18 версия 3.15

Программа аналогична программе написанной для TIC5234.  Но в отличие от 5234 у 5231 сегмерты во всех цифрах расположены соответсвенно, поэтому данная программа скорее всего избыточна.

Но время рассудит.

Код:
#pragma romdata eedata = 0xf00000
rom unsigned char Compile_date[]= __DATE__;
rom unsigned char Compile_time[]= __TIME__;
rom unsigned char Project_name[]= "LCD_5231_v1.0";
#pragma romdata eedata


/*Pin for - Load data from the shift register to data register;*/
#define	D_LOAD_L	DDRBbits.RB1=0; LATBbits.LATB1=0;
#define	D_LOAD_H	DDRBbits.RB1=0; LATBbits.LATB1=1;
/*Display data input pin;*/
#define	D_IN_L          DDRBbits.RB5=0; LATBbits.LATB5=0;
#define	D_IN_H          DDRBbits.RB5=0; LATBbits.LATB5=1;
/*Pin for the clock of the display data;*/
#define	D_CLK_L         DDRBbits.RB4=0; LATBbits.LATB4=0;
#define	D_CLK_H         DDRBbits.RB4=0; LATBbits.LATB4=1;

union segments{
	struct{
	unsigned  Sg_0:1;
	unsigned  Sg_1:1;
	unsigned  Sg_2:1;
	unsigned  Sg_3:1;
	unsigned  Sg_4:1;
	unsigned  Sg_5:1;
	unsigned  Sg_6:1;
	unsigned  Sg_7:1;
                };
	volatile unsigned char seg_bits;
	};
volatile union segments LCD_5231[5];

volatile union{
struct{
	unsigned  S_15_dot1:1;
	unsigned  S_30_dot2:1;
	unsigned :1;
	unsigned  S_38_one:1;
	unsigned  :2;
	unsigned  S_39_minus:1;
	unsigned  S_40_up_minus:1;
                };
	volatile unsigned char symbols;
	}symbols_5231;
volatile union segments LCD_5231_conv[5];	

void LCD_5231_conversion(void){
/////////////////////////
LCD_5231_conv[0].Sg_7 = LCD_5231[0].Sg_1;
LCD_5231_conv[0].Sg_6 = LCD_5231[0].Sg_2;
LCD_5231_conv[0].Sg_5 = LCD_5231[0].Sg_3;
LCD_5231_conv[0].Sg_4 = LCD_5231[0].Sg_4;
LCD_5231_conv[0].Sg_3 = LCD_5231[0].Sg_5;
LCD_5231_conv[0].Sg_2 = LCD_5231[0].Sg_6;
LCD_5231_conv[0].Sg_1 = LCD_5231[0].Sg_7;
LCD_5231_conv[0].Sg_0 = LCD_5231[1].Sg_1;
////////////////////////
LCD_5231_conv[1].Sg_7 = LCD_5231[1].Sg_2;
LCD_5231_conv[1].Sg_6 = LCD_5231[1].Sg_3;
LCD_5231_conv[1].Sg_5 = LCD_5231[1].Sg_4;
LCD_5231_conv[1].Sg_4 = LCD_5231[1].Sg_5;
LCD_5231_conv[1].Sg_3 = LCD_5231[1].Sg_6;
LCD_5231_conv[1].Sg_2 = LCD_5231[1].Sg_7;
LCD_5231_conv[1].Sg_1 = symbols_5231.S_15_dot1;
LCD_5231_conv[1].Sg_0 = LCD_5231[2].Sg_1;
/////////////////////////
LCD_5231_conv[2].Sg_7 = LCD_5231[2].Sg_2;
LCD_5231_conv[2].Sg_6 = LCD_5231[2].Sg_3;
LCD_5231_conv[2].Sg_5 = LCD_5231[2].Sg_4;
LCD_5231_conv[2].Sg_4 = LCD_5231[2].Sg_5;
LCD_5231_conv[2].Sg_3 = LCD_5231[2].Sg_6;
LCD_5231_conv[2].Sg_2 = LCD_5231[2].Sg_7;
LCD_5231_conv[2].Sg_1 = LCD_5231[3].Sg_1;
LCD_5231_conv[2].Sg_0 = LCD_5231[3].Sg_2;
/////////////////////////
LCD_5231_conv[3].Sg_7 = LCD_5231[3].Sg_3;
LCD_5231_conv[3].Sg_6 = LCD_5231[3].Sg_4;
LCD_5231_conv[3].Sg_5 = LCD_5231[3].Sg_5;
LCD_5231_conv[3].Sg_4 = LCD_5231[3].Sg_6;
LCD_5231_conv[3].Sg_3 = LCD_5231[3].Sg_7;
LCD_5231_conv[3].Sg_2 = symbols_5231.S_30_dot2;
LCD_5231_conv[3].Sg_1 = LCD_5231[4].Sg_1;
LCD_5231_conv[3].Sg_0 = LCD_5231[4].Sg_2;
/////////////////////////
LCD_5231_conv[4].Sg_7 = LCD_5231[4].Sg_3;
LCD_5231_conv[4].Sg_6 = LCD_5231[4].Sg_4;
LCD_5231_conv[4].Sg_5 = LCD_5231[4].Sg_5;
LCD_5231_conv[4].Sg_4 = LCD_5231[4].Sg_6;
LCD_5231_conv[4].Sg_3 = LCD_5231[4].Sg_7;
LCD_5231_conv[4].Sg_2 = symbols_5231.S_38_one;
LCD_5231_conv[4].Sg_1 = symbols_5231.S_39_minus;
LCD_5231_conv[4].Sg_0 = symbols_5231.S_40_up_minus;
////////////////////////
}
/*DELAY depend from frequency of your resonator*/
void LCD_ML1001_5231_Sst(unsigned char digit_1, unsigned char digit_2, unsigned char digit_3, unsigned char digit_4, unsigned char digit_5, unsigned char ssimv){
char i,temp, n;
LCD_5231[0].seg_bits = digit_1;
LCD_5231[1].seg_bits = digit_2;
LCD_5231[2].seg_bits = digit_3;
LCD_5231[3].seg_bits = digit_4;
LCD_5231[4].seg_bits = digit_5;
symbols_5231.symbols = ssimv;
LCD_5231_conversion();
D_CLK_L
D_LOAD_L
for(n = 4; n >= 0; n--){
	temp = LCD_5231_conv[n].seg_bits;
	for(i = 0; i <= 7; i++){
                        if(temp & 0x01){
                                D_IN_H
                                D_CLK_H
                                Nop();//DELAY
                                D_CLK_L
                                D_IN_L
                        }else{
                                D_IN_L
                                D_CLK_H
                                Nop();//DELAY
                                D_CLK_L
                                }
                                temp >>= 1;
                        }
                }
D_LOAD_H
Nop();//DELAY
D_LOAD_L
}


void main(void){
unsigned char i;
unsigned char Digits_523x[10]={0xfa,0x0a,0xb6,0x9e,0x4e,0xdc,0xfc,0x8a,0xfe,0xde};/*0,1,2,3,4,5,6,7,8,9*/
OSCCONbits.IRCF2 = 1;//
OSCCONbits.IRCF1 = 0;// 1MHz ??
OSCCONbits.IRCF0 = 0;//
//LCD_5231/S1_S2_S2_S4_S5_S6_S7_NULL; S15, S30 - DOTS; S38 - LEFT ONE; S39 - 'minus'; S40 -'UP MINUS'//LCD_5231//
while(1){
for (i=0; i<10; i++){
LCD_ML1001_5231_Sst(Digits_523x[i], Digits_523x[i], Digits_523x[i], Digits_523x[i], Digits_523x[i], 0x00);
Delay10KTCYx(25);
                }	
	}
}

Программа выводит цифры от 0 до 9 во всех разрядах с интервалом примерно в 1 секунду.

P. S.: В железе работает.


Вы здесь » PNP-LinE » Контроллеры и Компьютеры. » LCD TIC5231 и PIC