root/branch/leng/sp4b2/SP4b2/SP4b2.c @ 591
492 | jileng | /***********************************************************************/
|
|
/* */
|
|||
/* 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. */
|
|||
/***********************************************************************/
|
|||
509 | jileng | //importation bibliotheque
|
|
#include "sfr32c87.h"
|
|||
492 | jileng | ||
591 | jileng | 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)
|
|||
509 | jileng | {
|
|
591 | jileng | pd1=0xff;
|
|
p1=0x00;
|
|||
509 | jileng | }
|
|
591 | jileng | ||
509 | jileng | void decodeChar(char c){
|
|
591 | jileng | //affectation valeur de c aux bits de data de 4 ? 7
|
|
509 | jileng | if(c & 0x10){
|
|
591 | jileng | p1_4=1;
|
|
509 | jileng | }
|
|
591 | jileng | else{
|
|
p1_4=0;
|
|||
509 | jileng | }
|
|
591 | jileng | ||
509 | jileng | if(c & 0x20){
|
|
591 | jileng | p1_5=1;
|
|
509 | jileng | }
|
|
591 | jileng | else{
|
|
p1_5=0;
|
|||
}
|
|||
509 | jileng | ||
if(c & 0x80){
|
|||
591 | jileng | p1_6=1;
|
|
509 | jileng | }
|
|
591 | jileng | else{
|
|
p1_6=0;
|
|||
509 | jileng | }
|
|
591 | jileng | ||
509 | jileng | if(c & 0xf0){
|
|
591 | jileng | p1_7=1;
|
|
509 | jileng | }
|
|
591 | jileng | else{
|
|
p1_7=0;
|
|||
509 | jileng | }
|
|
}
|
|||
591 | jileng | void decodeCharfaible(char c){
|
|
509 | jileng | if(c & 0x01){
|
|
591 | jileng | p1_0=1;
|
|
509 | jileng | }
|
|
591 | jileng | else{
|
|
p1_0=0;
|
|||
509 | jileng | }
|
|
if(c & 0x02){
|
|||
591 | jileng | p1_1=1;
|
|
509 | jileng | }
|
|
591 | jileng | else{
|
|
p1_1=0;
|
|||
509 | jileng | }
|
|
if(c & 0x08){
|
|||
591 | jileng | p1_2=1;
|
|
509 | jileng | }
|
|
591 | jileng | else{
|
|
p1_2=0;
|
|||
509 | jileng | }
|
|
if(c & 0x0f){
|
|||
591 | jileng | p1_3=1;
|
|
509 | jileng | }
|
|
591 | jileng | else{
|
|
p1_3=0;
|
|||
509 | jileng | }
|
|
}
|
|||
void Lcd4b(char c){
|
|||
591 | jileng | p1_2=1;
|
|
509 | jileng | decodeChar(c);
|
|
591 | jileng | p1_2=0;
|
|
509 | jileng | }
|
|
void Lcd8b(char c){
|
|||
591 | jileng | p1_2=1;
|
|
509 | jileng | decodeChar(c);
|
|
591 | jileng | decodeCharfaible(c);
|
|
p1_2=0;
|
|||
509 | jileng | }
|
|
void LcdCom(char c){
|
|||
591 | jileng | 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);
|
|||
}
|
|||
509 | jileng | ||
591 | jileng | 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);
|
|||
}
|
|||
509 | jileng | ||
591 | jileng | void LcdChar(char c){
|
|
p1_0=1;
|
|||
509 | jileng | Lcd8b(c);
|
|
}
|
|||
591 | jileng | /*
|
|
void tpo_ms(int a){
|
|||
tcspr = 0x8A;
|
|||
ta0mr = 0x82;
|
|||
ta0 = a*1000;
|
|||
ta0s = 1;ta0os = 1;
|
|||
ta0ic = 0x00;
|
|||
while(ir_ta0ic != 1);
|
|||
ta0s = 0;
|
|||
509 | jileng | }
|
|
591 | jileng | void tpo_us(int a){
|
|
tcspr = 0x8A;
|
|||
ta0mr = 0x82;
|
|||
ta0 = a;
|
|||
ta0s = 1;ta0os = 1;
|
|||
ta0ic = 0x00;
|
|||
while(ir_ta0ic != 1);
|
|||
ta0s = 0;
|
|||
509 | jileng | }
|
|
591 | jileng | */
|
|
509 | jileng | ||