Projet

Général

Profil

« Précédent | Suivant » 

Révision 483

Ajouté par Ely SENE il y a presque 4 ans

Afficheur séance b2

Voir les différences:

SP4b2.c
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
/***********************************************************************/
#include "sfr32c87.h"
#define LCD_E
#define LCD_DC
void lcd_4b(unsigned char c){
p3_2=1;
if(c&0x80){
p3_7=1;
}
else{
p3_7=0;
}
if(c&0x40){
p3_6=1;
}
else{
p3_6=0;
}
if(c&0x20){
p3_5=1;
}
else{
p3_5=0;
}
if(c&0x10){
p3_4=1;
}
else{
p3_4=0;
}
p3_2=0;
}
void lcd_8b(char c)
{
lcd_4b(c);
lcd_4b(c<<4);
}
void lcd_com(char c)
{
p3_0=0;
lcd_8b(c);
}
void tpo_ms(int t)
{
tcspr = 0x8A;
ta0mr = 0x82;
ta0 = t*1000;
ta0s = 1;ta0os = 1;
ta0ic = 0x00;
while(ir_ta0ic != 1);
ta0s = 0;
}
void tpo_us(int t)
{
tcspr = 0x8A;
ta0mr = 0x82;
ta0 = t;
ta0s = 1;ta0os = 1;
ta0ic = 0x00;
while(ir_ta0ic != 1);
ta0s = 0;
}
void lcd_init(void)
{
pd3=0xff;
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);
}
void lcd_char(char c)
{
p3_0=1;
lcd_8b(c);
}
void main(void)
{
}
{
char c;
lcd_init();
lcd_4b(0xf0);
lcd_8b(0xf0);
lcd_char('E');
lcd_char('L');
lcd_char('Y');
}

Formats disponibles : Unified diff