Révision 539
Ajouté par albeaufour il y a presque 4 ans
SP4b2.c | ||
---|---|---|
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
||
/***********************************************************************/
|
||
#include "sfr32c87.h"
|
||
|
||
#define PLCD p3;
|
||
#define LCD_DC p3_0;
|
||
#define LCD_RW P3_1;
|
||
... | ... | |
void lcd_init(void);// initialisation de l'afficheur
|
||
void lcd_str(unsigned char *str);// envoi d'une cha?ne de caract?re
|
||
|
||
//LCD//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
void init_keyboard(void);
|
||
void tpo_50ms(void) ;
|
||
|
||
|
||
void init_keyboard(void)
|
||
{
|
||
pd10 = 0x0F;
|
||
p10=0 ;
|
||
pu31 = 1;
|
||
}
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
||
|
||
void lcd_4b(unsigned char c)
|
||
{
|
||
|
||
... | ... | |
tcspr = 0x8A;
|
||
ta0mr = 0x82;
|
||
ta0 = duree;
|
||
ta0s = 1;ta0os = 1;
|
||
ta0s = 1;
|
||
ta0os = 1;
|
||
ta0ic = 0x00;
|
||
while(ir_ta0ic != 1);
|
||
ta0s = 0;
|
||
... | ... | |
}
|
||
|
||
|
||
void lcd_car(unsigned char car)
|
||
{
|
||
p3_0 = 1;
|
||
lcd_8b(car);
|
||
}
|
||
|
||
void lcd_str(unsigned char *str)
|
||
{
|
||
int i = 0;
|
||
while (*(str+i) != '\0')
|
||
{
|
||
lcd_car (*(str+i));
|
||
i++;
|
||
}
|
||
}
|
||
|
||
void lcd_clear (void)
|
||
{
|
||
lcd_com(0x01);
|
||
}
|
||
|
||
void main(void)
|
||
{
|
||
char tab[4][3]={{'1','2','3'}, // L C D ////////////////////////
|
||
{'4','5','6'},
|
||
{'7','8','9'},
|
||
{'*','0','#'}};
|
||
char resultat; // L C D ////////////////////////
|
||
init_keyboard(); // L C D ////////////////////////
|
||
int i;
|
||
lcd_init();
|
||
while(1) //*** fonction
|
||
{
|
||
short int colone, ligne;
|
||
if ( (p10 & 0xf0)!= 0xf0 ) //le programme attend qu'une touche soit press? //**** bit fort != 1 -> touche press?e
|
||
{
|
||
if (p10 == 0xB0) //Je test les diff?rentes colone pour identifi? dans laquel on ce situe
|
||
{colone=0;}
|
||
if (p10 == 0xE0) //Je test les diff?rentes colone pour identifi? dans laquel on ce situe
|
||
{colone=0;}
|
||
if (p10 == 0xD0) //((p10 & 0xf0) == 0xD0)
|
||
{colone=1;}
|
||
if (p10 == 0x70)
|
||
{colone=2;}
|
||
|
||
p10 = 0x0E; //Je test les diff?rentes ligne pour identifi? dans laquel on ce situe
|
||
if ((p10 & 0xF0)!= 0xF0)
|
||
{ligne = 0;}
|
||
p10 = 0x0D;
|
||
if ((p10 & 0xF0)!= 0xF0)
|
||
{ligne = 1;}
|
||
p10 = 0x0B;
|
||
if ((p10 & 0xF0)!= 0xF0)
|
||
{ligne = 2;}
|
||
p10 = 0x07;
|
||
if ((p10 & 0xF0)!= 0xF0)
|
||
{ligne = 3;}
|
||
|
||
|
||
|
||
resultat = tab[ligne][colone];
|
||
lcd_clear ();
|
||
for (i=0;i<=20;i++)
|
||
{
|
||
tpo_ms(50);
|
||
}
|
||
lcd_car(resultat);
|
||
|
||
|
||
}
|
||
p10 = 0;
|
||
}
|
||
|
||
}
|
Formats disponibles : Unified diff
concatenation des code TPb2 et TPb1