Projet

Général

Profil

« Précédent | Suivant » 

Révision 535

Ajouté par clbouillot2 il y a presque 4 ans

couplage lcd et clavier

Voir les différences:

SP4b2.c
void lcd_4b (char c) {
char valeur4b;
p3_2=1; //fonction permettant la r?ception des donn?es par l'afficheur
p3_7=(c & 0b10000000)>>7;
p3_6=(c & 0b01000000)>>6;
p3_5=(c & 0b00100000)>>5;
p3_4=(c & 0b00010000)>>4;
p3_2=0;
}
void tpo_ms (unsigned short duree){
p3_4=(c & 0b0001);
p3_5=(c & 0b0010)>>1;
p3_6=(c & 0b0100)>>2;
p3_7=(c & 0b1000)>>3;
duree = duree*1000;
tcspr = 0x8A;
ta0mr = 0x82;
ta0 = duree;
ta0s = 1;ta0os = 1;
ta0ic = 0x00;
while (ir_ta0ic != 1);
ta0s = 0;
}
void tpo_us (unsigned short duree){
p3_2=0;
}
tcspr = 0x8A;
ta0mr = 0x82;
ta0 = duree;
ta0s = 1;ta0os = 1;
ta0ic = 0x00;
while (ir_ta0ic != 1);
ta0s = 0;
}
void lcd_8b (char c) {
lcd_4b(c);
......
}
void lcd_car (char c) {
p3_0=1;
lcd_8b(c);
}
void lcd_str (char *str){
int i = 0;
while (str[i]!='\0')
{
lcd_car(str[i]);
i++;
}
}
// initialize the LCD display
void lcd_init(void)
......
pd3=0xFF;
p3=0x00;
p3_0=0 ;
//tpo_ms(15);
lcd_4b(0x03);
//tpo_ms(5);
lcd_4b(0x03);
//tpo_us(100);
lcd_4b(0x03);
//tpo_us(100);
lcd_4b(0x02);
lcd_com(0x82);
lcd_com(0x60);
lcd_com(0xE0);
lcd_com(0x10);
//tpo_ms(5);
tpo_ms(15);
lcd_4b(0x30);
tpo_ms(5);
lcd_4b(0x30);
tpo_us(100);
lcd_4b(0x30);
tpo_us(100);
lcd_4b(0x20);
lcd_com(0x28);
lcd_com(0x06);
lcd_com(0x0E);
lcd_com(0x01);
tpo_ms(5);
}
void init_keyboard(void){
pd10 = 0x0f;
p10=0 ;
pu31 = 1;
}
void main(void){
//LCD_E=1;
lcd_init();
void tpo_50ms(void){
tcspr = 0x8A;
ta0mr = 0x82;
ta0 = 50000;
ta0s = 1;ta0os = 1;
ta0ic = 0x00;
while(ir_ta0ic != 1);
ta0s = 0;
}
unsigned char touche_c = 0;
unsigned char touche_appuyee;
void main(void){
init_keyboard();
lcd_init();
while(1){
init_keyboard();
if ( (p10 & 0xf0)!= 0xf0 ){ //les colonnes sont en entr?es
touche_c = p10 ;
tpo_50ms() ; // une temporisation entre en oeuvre pour ?viter les ph?nom?nes de rebond
p10 = 0x0e;
if ( (p10 & 0xff)== 0xbe ){ //diff?rents tests
touche_appuyee = '1';
}
if ( (p10 & 0xff)== 0xde ){
touche_appuyee = '2';
}
if ( (p10 & 0xff)== 0x7e ){
touche_appuyee = '3';
}
p10 = 0x0d;
if ( (p10 & 0xff)== 0xbd ){
touche_appuyee = '4';
}
if ( (p10 & 0xff)== 0xdd ){
touche_appuyee = '5';
}
if ( (p10 & 0xff)== 0x7d ){
touche_appuyee = '6';
}
p10 = 0x0b;
if ( (p10 & 0xff)== 0xeb ){
touche_appuyee = '7';
}
if ( (p10 & 0xff)== 0xdb ){
touche_appuyee = '8';
}
if ( (p10 & 0xff)== 0x7b ){
touche_appuyee = '9';
}
p10 = 0x07;
if ( (p10 & 0xff)== 0xe7 ){
touche_appuyee = '*';
}
if ( (p10 & 0xff)== 0xd7 ){
touche_appuyee = '0';
}
if ( (p10 & 0xff)== 0x77 ){
touche_appuyee = '#';
}
lcd_car(touche_appuyee);
lcd_init();
}
}
} +

Formats disponibles : Unified diff