|
/***********************************************************************/
|
|
/* */
|
|
/* FILE :SP4b1.c */
|
|
/* DATE :Tue, May 18, 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"
|
|
|
|
/*#define LCD_PORT p1
|
|
#define LCD_PORT_DIR 1
|
|
#define LCD_E LCD_PORT_2
|
|
#define LCD_RW LCD_PORT_1
|
|
#define LCD_DC LCD_PORT_0
|
|
#define LCD_E_DIR LCD_PORT_DIR
|
|
#define LCD_RW_DIR LCD_PORT_DIR
|
|
#define LCD_DC_DIR LCD_PORT_DIR*/
|
|
|
|
//Commande de l'afficheur
|
|
void tpo_us(int duree){
|
|
tcspr=0x8A;
|
|
ta0mr=0x82;
|
|
ta0=duree*1000;
|
|
ta0s=1;
|
|
ta0os=1;
|
|
ta0ic=0x00;
|
|
while(ir_ta0ic !=1);
|
|
ta0os=0;
|
|
}
|
|
|
|
void tpo_ms(int duree){
|
|
tcspr=0x8A;
|
|
ta0mr=0x82;
|
|
ta0=duree*1000000;
|
|
ta0s=1;
|
|
ta0os=1;
|
|
ta0ic=0x00;
|
|
while(ir_ta0ic !=1);
|
|
ta0os=0;
|
|
}
|
|
|
|
void lcd_4b(unsigned char car){
|
|
pd3=0xFF;
|
|
p3_2=1;
|
|
if (car&0b10000000){
|
|
p3_7=1;
|
|
}
|
|
else{
|
|
p3_7=0;
|
|
}
|
|
if (car&0b01000000){
|
|
p3_6=1;
|
|
}
|
|
else{
|
|
p3_6=0;
|
|
}
|
|
if (car&0b00100000){
|
|
p3_5=1;
|
|
}
|
|
else{
|
|
p3_5=0;
|
|
}
|
|
if (car&0b00010000){
|
|
p3_4=1;
|
|
}
|
|
else{
|
|
p3_4=0;
|
|
}
|
|
p3_2=0;
|
|
}
|
|
|
|
|
|
|
|
void lcd_8b(unsigned char car){
|
|
lcd_4b(car);
|
|
lcd_4b(car<<4);
|
|
}
|
|
|
|
void lcd_com(unsigned char com){
|
|
p3_0=0;
|
|
lcd_8b(com);
|
|
}
|
|
|
|
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_car(unsigned char car){
|
|
p3_0=1;
|
|
lcd_8b(car);
|
|
}
|
|
|
|
void lcd_str(unsigned char *str){
|
|
int i=0;
|
|
|
|
while(str[i]!='\0'){
|
|
lcd_car(str[i]);
|
|
i++;
|
|
}
|
|
}
|
|
|
|
void main (void){
|
|
lcd_init();
|
|
//lcd_str("hello world");
|
|
}
|
|
|
|
|
|
/*id init_keyboard(void);
|
|
void tpo_50ms(void);
|
|
|
|
unsigned char touche = 0;
|
|
|
|
void main(void){
|
|
init_keyboard();
|
|
while(1){
|
|
if ( (p10 & 0xf0)!= 0xf0 ){
|
|
touche=p10;
|
|
tpo_50ms();
|
|
}
|
|
}
|
|
}
|
|
void init_keyboard(void){
|
|
pd10=0x0F;
|
|
p10=0;
|
|
pu31 = 1;
|
|
}
|
|
|
|
void tpo_50ms(void){
|
|
tcspr=0x8A; ta0mr = 0x82; ta0 = 50000;
|
|
ta0s=1;
|
|
ta0os=1;
|
|
ta0ic=0x00;
|
|
|
|
while(ir_ta0ic != 1);
|
|
ta0s=0;
|
|
}*/
|
|
/*char touche;
|
|
char t;
|
|
void main(void){
|
|
pd10=0x0F;
|
|
p10=0x00;
|
|
pu31=0xFF;
|
|
pu30=0xFF;
|
|
while(1){
|
|
p10=0b11110111;
|
|
if((p10&0x0F)!=0x0F){
|
|
t=p10;
|
|
}
|
|
p10=0b11111011;
|
|
if((p10&0x0F)!=0x0F){
|
|
t=p10;
|
|
}
|
|
p10=0b11111101;
|
|
if((p10&0x0F)!=0x0F){
|
|
t=p10;
|
|
}
|
|
p10=0b11111110;
|
|
if((p10&0x0F)!=0x0F){
|
|
t=p10;
|
|
}
|
|
/*switch(p10){
|
|
case 0xe1 :
|
|
touche='*';
|
|
case 0xd1 :
|
|
touche='0';
|
|
case 0x71 :
|
|
touche='#';
|
|
case 0xeb :
|
|
touche='7';
|
|
case 0xdb :
|
|
touche='8';
|
|
case 0x7b :
|
|
touche='9';
|
|
case 0xbd :
|
|
touche='4';
|
|
case 0xdd :
|
|
touche='5';
|
|
case 0x7d :
|
|
touche='6';
|
|
case 0xbe :
|
|
touche='1';
|
|
case 0xde :
|
|
touche='2';
|
|
case 0x7e :
|
|
touche='3';
|
|
}*/
|
|
|
|
/*if(p10==0xe1){
|
|
touche='*';
|
|
}
|
|
if (p10=0xd1){
|
|
touche='0';
|
|
}
|
|
if (p10=0x71){
|
|
touche='#';
|
|
}*/
|
|
|
|
/*if (p10=0xeb){
|
|
touche='7';
|
|
}
|
|
if (p10=0xdb){
|
|
touche='8';
|
|
}
|
|
if (p10=0x7b){
|
|
touche='9';
|
|
}*/
|
|
|
|
/*if (p10=0xbd){
|
|
touche='4';
|
|
}
|
|
if (p10=0xdd){
|
|
touche='5';
|
|
}
|
|
if (p10=0x7d){
|
|
touche='6';
|
|
}*/
|
|
|
|
//if (p10=0xbe){
|
|
//touche='1';
|
|
//}
|
|
//if (p10=0xde){
|
|
//touche='2';
|
|
//}
|
|
//if (p10=0x7e){
|
|
//touche='3';
|
|
//}
|
|
//}
|
|
//}
|
|
|
|
|
|
|