Révision 489
Ajouté par malameynar il y a presque 4 ans
SP4b1.c | ||
---|---|---|
/***********************************************************************/
|
||
|
||
#include "sfr32c87.h"
|
||
/*char touche;
|
||
char t;
|
||
void main(){
|
||
|
||
void decode_touche(){
|
||
char touche;
|
||
char t;
|
||
pd10=0x0f;
|
||
pu31=1;
|
||
p10=0x00;
|
||
... | ... | |
}
|
||
}
|
||
}
|
||
*/
|
||
|
||
/*
|
||
void init_keyboard(void);
|
||
void tpo_50ms(void);
|
||
... | ... | |
}
|
||
*/
|
||
|
||
lcd_4b(char c){
|
||
#define LCD_E p3_2
|
||
#define LCD_RW p3_1
|
||
#define LCD_DC p3_0
|
||
#define LCD_PORT pd3
|
||
|
||
void lcd_4b(char c){
|
||
|
||
p12=1;
|
||
|
||
LCD_E=1; //E
|
||
|
||
if(c&0x80){
|
||
p1_7=1;
|
||
p3_7=1;
|
||
}
|
||
else{
|
||
p1_7=0;
|
||
p3_7=0;
|
||
}
|
||
|
||
if(c&0x40){
|
||
p1_6=1;
|
||
p3_6=1;
|
||
}
|
||
else{
|
||
p1_6=0;
|
||
p3_6=0;
|
||
}
|
||
|
||
if(c&0x20){
|
||
p1_5=1;
|
||
p3_5=1;
|
||
}
|
||
else{
|
||
p1_5=0;
|
||
p3_5=0;
|
||
}
|
||
|
||
if(c&0x10){
|
||
p1_4=1;
|
||
p3_4=1;
|
||
}
|
||
else{
|
||
p1_4=0;
|
||
p3_4=0;
|
||
}
|
||
|
||
|
||
|
||
p12=0;
|
||
LCD_E=0;
|
||
}
|
||
|
||
lcd_8b(
|
||
void lcd_8b(char c){
|
||
lcd_4b(c);
|
||
lcd_4b(c<<4);
|
||
}
|
||
void lcd_com(char c){
|
||
LCD_DC=0;
|
||
lcd_8b(c);
|
||
}
|
||
void lcd_char( char c){
|
||
LCD_DC=1;
|
||
lcd_8b(c);
|
||
}
|
||
|
||
void tpo_us(unsigned short duree){
|
||
tcspr = 0x8A;
|
||
ta0mr = 0x82;
|
||
ta0= duree;
|
||
ta0s = 1;ta0os = 1;
|
||
ta0ic = 0x00;
|
||
while(ir_ta0ic != 1);
|
||
ta0s = 0;
|
||
}
|
||
|
||
|
||
|
||
|
||
void lcd_init(void){
|
||
LCD_DC=0;
|
||
tpo_us(15000);
|
||
lcd_4b(0x30);
|
||
tpo_us(5000);
|
||
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_us(5000);
|
||
}
|
||
|
||
void main(){
|
||
pd1=0xFF;
|
||
|
||
while(1){
|
||
lcd_4b(0xF0);
|
||
}
|
||
LCD_PORT=0xFF;
|
||
lcd_init();
|
||
lcd_char('M');
|
||
decode_touche();
|
||
|
||
}
|
Formats disponibles : Unified diff
fin TP b2