void init_port(void);
void outdata(char);
void outcontrol(char);
void delay1(int);
void Lcd_control_write(void);
void init_Lcd(void);
void write_data(char);
void setup() {
  init_port();
  outdata(0x38); //8bit 2 line
  Lcd_control_write();
  outdata(0x0f);   //  display on cursor blinking
    Lcd_control_write();
    outdata(0x01); // clear data
      Lcd_control_write();
    outdata(0x06);//auto increment
     Lcd_control_write();
      outdata(0x84); //8bit 2 line
  Lcd_control_write();
  write_string("welcome");

   outdata(0x14); //8bit 2 line
  Lcd_control_write();
  outdata(0x06);//auto increment
     Lcd_control_write();
     outdata(0xc0); //8bit 2 line
  Lcd_control_write();
   write_string("To Ecen Academy");

}
void loop() {
}
void init_port()
{
  volatile char* portf_dir=(volatile char*)0x30;
  volatile char* portk_dir=(volatile char*)0x107;
  *portf_dir=0xff;
  *portk_dir=0x03;
}
void outdata(char out_data)
{
  volatile char* portf_data=(volatile char*)0x31;
  *portf_data=out_data;
}
void write_string(char *ptr)
{
  while(*ptr!=0)
  {
    write_data(*ptr);
    ptr++;
  }
}
void outcontrol(char out_data)
{
  volatile char *portk_data=(volatile char*)0x108;
  *portk_data=out_data;
}
void Lcd_control_write(void)
{
  outcontrol(0x01);
  delay(1);
  outcontrol(0x00);
   delay(1);
}
void init_Lcd(void)
{
  outdata(0x38); //8bit 2 line
  Lcd_control_write();
  outdata(0x0f);   //  display on cursor blinking
    Lcd_control_write();
    outdata(0x01); // clear data
      Lcd_control_write();
    outdata(0x06);//auto increment
     Lcd_control_write();
      outdata(0x84); //8bit 2 line
  Lcd_control_write();
}
void write_data(char wr_data)
{
  outdata(wr_data);
  outcontrol(0x02);
  delay(1);
  outcontrol(0x03);
  delay(1);
  outcontrol(0x02);
  delay(1);
}