|
/***********************************************************************/
|
|
/* */
|
|
/* FILE :SP4b2.c */
|
|
/* DATE :Fri, May 28, 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. */
|
|
/***********************************************************************/
|
|
|
|
#include "sfr32c87.h"
|
|
//prototype
|
|
void lcd_4b(unsigned char car);
|
|
void lcd_8b(unsigned char car);
|
|
void lcd_car(unsigned char car);
|
|
void lcd_com(unsigned char com);
|
|
void lcd_init(void);
|
|
|
|
|
|
void main(void)
|
|
{
|
|
/* pd1=0xff; // definit en sortie
|
|
p1_2=1; //E=1
|
|
p1_7=1; */
|
|
pd3=0xff;
|
|
lcd_4b(0xAA); // test fonction 4bits
|
|
lcd_8b(0x8F); // test fonction 8bits
|
|
lcd_car(0x8F);
|
|
lcd_com(0x8F);
|
|
|
|
}
|
|
void lcd_4b(unsigned char car)
|
|
{
|
|
if(car & 0x80)
|
|
{
|
|
p3_7=1;
|
|
}
|
|
else
|
|
{
|
|
p3_7=0;
|
|
}
|
|
if(car & 0x40)
|
|
{
|
|
p3_6=1;
|
|
}
|
|
else
|
|
{
|
|
p3_6=0;
|
|
}
|
|
if(car & 0x20)
|
|
{
|
|
p3_5=1;
|
|
}
|
|
else
|
|
{
|
|
p3_5=0;
|
|
}
|
|
if(car & 0x10)
|
|
{
|
|
p3_4=1;
|
|
}
|
|
else
|
|
{
|
|
p3_4=0;
|
|
}
|
|
|
|
}
|
|
void lcd_8b(unsigned char car)
|
|
{
|
|
lcd_4b(car); // affichage des bits de poids fort
|
|
lcd_4b(car<<4); // affichage des bits de poids faible
|
|
}
|
|
void lcd_car(unsigned char car)
|
|
{
|
|
p3_0=1;
|
|
lcd_8b(car);
|
|
}
|
|
void lcd_com(unsigned char com)
|
|
{
|
|
p3_0=0;
|
|
lcd_8b(com);
|
|
}
|
|
// initialize the LCD display
|
|
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);
|
|
}
|
|
|
|
|
|
|