Projet

Général

Profil

/***********************************************************************/
/* */
/* FILE :SP4b2.c */
/* DATE :Tue, May 25, 2021 */
/* DESCRIPTION :main program file. */
/* CPU GROUP :87B */
/* */
/* This file is generated by Renesas Project Generator (Ver.4.18). */
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
/***********************************************************************/
//importation bibliotheque
#include "sfr32c87.h"

void initPort3(void);

void decodeChar(char c);

void decodeCharfaible(char c);

void Lcd4b(char c);

void Lcd8b(char c);

void LcdCom(char c);

void Lcd_init(void);

void LcdChar(char c);

void tpo_ms(int a) ;

void tpo_us(int a);

void main(void){
while(1){
pd1=0xff;
p1=0x00;
initPort3();
Lcd4b(0x00);
initPort3();
Lcd8b(0x35);
/*initPort3();
Lcd_init();
LcdChar('A');
LcdChar('test');
*/

}

}
void initPort3(void)
{
pd1=0xff;
p1=0x00;
}

void decodeChar(char c){
//affectation valeur de c aux bits de data de 4 ? 7
if(c & 0x10){
p1_4=1;
}
else{
p1_4=0;
}

if(c & 0x20){
p1_5=1;
}
else{
p1_5=0;
}

if(c & 0x80){
p1_6=1;
}
else{
p1_6=0;
}

if(c & 0xf0){
p1_7=1;
}
else{
p1_7=0;
}
}

void decodeCharfaible(char c){
if(c & 0x01){
p1_0=1;
}
else{
p1_0=0;
}

if(c & 0x02){
p1_1=1;
}
else{
p1_1=0;
}

if(c & 0x08){
p1_2=1;
}
else{
p1_2=0;
}

if(c & 0x0f){
p1_3=1;
}
else{
p1_3=0;
}
}

void Lcd4b(char c){
p1_2=1;
decodeChar(c);
p1_2=0;
}

void Lcd8b(char c){
p1_2=1;
decodeChar(c);
decodeCharfaible(c);
p1_2=0;
}

void LcdCom(char c){
p1=0;
/*
//display on
p3_7=1;p3_6=1;p3_5=1;
//mode entree
p3=0;
p3_6=1;p3_5=1;
*/
//ecriture car
Lcd8b(c);
}

void Lcd_init(void)
{
p1_0=0;
tpo_ms(15);
Lcd4b(0x30);
tpo_ms(5);
Lcd4b(0x30);
tpo_us(100);
Lcd4b(0x30);
tpo_us(100);
Lcd4b(0x20);
LcdCom(0x28);
LcdCom(0x06);
LcdCom(0x0E);
LcdCom(0x01);
tpo_ms(5);

}

void LcdChar(char c){
p1_0=1;
Lcd8b(c);
}

/*
void tpo_ms(int a){
tcspr = 0x8A;
ta0mr = 0x82;
ta0 = a*1000;
ta0s = 1;ta0os = 1;
ta0ic = 0x00;
while(ir_ta0ic != 1);
ta0s = 0;
}

void tpo_us(int a){
tcspr = 0x8A;
ta0mr = 0x82;
ta0 = a;
ta0s = 1;ta0os = 1;
ta0ic = 0x00;
while(ir_ta0ic != 1);
ta0s = 0;
}
*/






(2-2/9)