Révision 478
Ajouté par ahkurklu il y a plus de 4 ans
| Sp4b2.c | ||
|---|---|---|
|
#include"sfr32c87.h"
|
||
|
|
||
|
void lcd_4b(unsigned char car);
|
||
|
void lcd_8b(unsigned char car);
|
||
|
void lcd_com(unsigned char car);
|
||
|
void lcd_char(unsigned char car);
|
||
|
void lcd_init(void);
|
||
|
void tpo_us(unsigned short duree);
|
||
|
void tpo_ms(unsigned short duree);
|
||
|
void lcd_str(unsigned char * str);
|
||
|
|
||
|
|
||
|
void main(void){
|
||
|
pd1 = 0xff;
|
||
|
lcd_4b(0xA0);
|
||
|
|
||
|
pd3 = 0xff;
|
||
|
lcd_init();
|
||
|
lcd_char('A');
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void lcd_4b(unsigned char car){
|
||
|
|
||
|
p1_2 = 1;
|
||
|
p3_2 = 1;
|
||
|
if(car & 0x10){
|
||
|
p1_4 = 1;
|
||
|
p3_4 = 1;
|
||
|
}
|
||
|
else{
|
||
|
p1_4 = 0;
|
||
|
p3_4 = 0;
|
||
|
}
|
||
|
|
||
|
if(car & 0x20){
|
||
|
p1_5 = 1;
|
||
|
p3_5 = 1;
|
||
|
}
|
||
|
else{
|
||
|
p1_5 = 0;
|
||
|
p3_5 = 0;
|
||
|
}
|
||
|
|
||
|
if(car & 0x40){
|
||
|
p1_6 = 1;
|
||
|
p3_6 = 1;
|
||
|
}
|
||
|
else{
|
||
|
p1_6 = 0;
|
||
|
p3_6 = 0;
|
||
|
}
|
||
|
if(car & 0x80){
|
||
|
p1_7 = 1;
|
||
|
p3_7 = 1;
|
||
|
}
|
||
|
else{
|
||
|
p1_7 = 0;
|
||
|
p3_7 = 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
p1_2 = 0;
|
||
|
p3_2 = 0;
|
||
|
}
|
||
|
|
||
|
void lcd_8b(unsigned char car){
|
||
|
lcd_4b(car);
|
||
|
lcd_4b(car << 4);
|
||
|
|
||
|
}
|
||
|
|
||
|
void lcd_com(unsigned char car){
|
||
|
p3_0 = 0;
|
||
|
lcd_8b(car);
|
||
|
}
|
||
|
|
||
|
void lcd_char(unsigned char car){
|
||
|
p3_0 = 1;
|
||
|
lcd_8b(car);
|
||
|
}
|
||
|
|
||
|
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 tpo_ms(unsigned short duree){
|
||
|
tpo_us(duree*1000);
|
||
|
}
|
||
|
|
||
|
void lcd_str(unsigned char * str){
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
void lcd_init(void){
|
||
|
p3_0 = 0;
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
Formats disponibles : Unified diff
Implémentation fonction 4b,8b,car,com,init,tmp ms, tmp us