/*
 * File:   LCD.c
 * Author: Christian Mares
 *
 * Created on 11 de enero de 2019
 */

/*

#include "main.h"

#define LCD_F_INSTR         2    //   2 == 50us                     // Define a fast instruction execution time in terms of loop time (typically > 43us_
#define LCD_S_INSTR         6    //   6 == 150us                    // Define a slow instruction execution time in terms of loop time (typically > 1.35ms)
#define LCD_STARTUP         120  // 120 == 30ms                     // Define the startup time for the LCD in terms of loop time (typically > 30ms)

#define LCD_MAX_COLUMN      16

void Inic_LCD( void){
  // PMP initialization
  PMCON  = 0x83BF;             // Enable the PMP
  PMMODE = 0x03FF;             // Master Mode 1
  PMAEN  = 0x0001;             // PMA0 enabled

  // initialise TMR1
//  T1CON = 0x8030;             // Fosc/2, prescaled 1:256, 16us/tick

  // wait for >30ms
  delay2(LCD_STARTUP);

  //initiate the HD44780 display 8-bit init sequence
  PMADDR = LCDCMD;            // command register
  PMDATA = 0b00111000;        // 8-bit interface, 2 lines, 5x7
  delay2(LCD_S_INSTR);

  PMDATA = 0b00001110;        // display ON, cursor off, blink off
  delay2(LCD_S_INSTR);

  PMDATA = 0b00000001;        // clear display
  delay2(LCD_STARTUP+LCD_F_INSTR);

  PMDATA = 0b00000110;        // increment cursor, no shift
  delay2(LCD_STARTUP+LCD_S_INSTR);
  
//  PMDATA = 0b01000000;        
//  LCD_Wait(21000);
//  
//  PMADDR = LCDDATA;            
//  PMDATA = 0b10101101;
//  LCD_Wait(21000);
////  
////    PMADDR = LCDCMD; 
////    PMDATA = 0b01000000;        
////  LCD_Wait(21000);
////  
////  PMADDR = LCDDATA;            
//  PMDATA = 0b10101101;
//  LCD_Wait(21000);
////  
////    PMADDR = LCDCMD; 
//    PMDATA = 0b0100001;        
//  LCD_Wait(21000);
////  
////  PMADDR = LCDDATA;            
//  PMDATA = 0b10101101;
//  LCD_Wait(21000);
////  
////    PMADDR = LCDCMD; 
//    PMDATA = 0b01000010;        
//  LCD_Wait(21000);
////  
////  PMADDR = LCDDATA;            
//  PMDATA = 0b10101101;
//  LCD_Wait(21000);
////  
////    PMADDR = LCDCMD; 
//    PMDATA = 0b01000011;        
//  LCD_Wait(21000);
////  
////  PMADDR = LCDDATA;            
//  PMDATA = 0b10101101;
//  LCD_Wait(21000);
////  
////    PMADDR = LCDCMD; 
//    PMDATA = 0b01000100;        
//  LCD_Wait(21000);
////  
////  PMADDR = LCDDATA;            
//  PMDATA = 0b10101101;
//  LCD_Wait(21000);
////  
////    PMADDR = LCDCMD; 
//    PMDATA = 0b01000101;        
//  LCD_Wait(21000);
////  
////  PMADDR = LCDDATA;            
//  PMDATA = 0b10101101;
//  LCD_Wait(21000);
////  
////    PMADDR = LCDCMD; 
//    PMDATA = 0b01000110;        
//  LCD_Wait(21000);
////  
////  PMADDR = LCDDATA;            
//  PMDATA = 0b10101101;
//  LCD_Wait(21000);
////  
////    PMADDR = LCDCMD; 
//    PMDATA = 0b01000111;        
//  LCD_Wait(21000);
////  
////  PMADDR = LCDDATA;            
//  PMDATA = 0b10101101;
//  LCD_Wait(21000);
//  
////  PMDATA = 0b01000111;        
////  LCD_Wait(21000);
////  
////  PMADDR = LCDDATA;            
//  PMDATA = 0b10101101;
//  LCD_Wait(21000);
////  LCD_SetCustomChar(0xf);
////  escribirLCD(0x0f,);
  
}

 * */