#define MX_PIC
//Defines for microcontroller
#define P16F877A
#define MX_EE
#define MX_EE_TYPE2
#define MX_EE_SIZE 256
#define MX_SPI
#define MX_SPI_C
#define MX_SPI_SDI 4
#define MX_SPI_SDO 5
#define MX_SPI_SCK 3
#define MX_UART
#define MX_UART_C
#define MX_UART_TX 6
#define MX_UART_RX 7
#define MX_I2C
#define MX_MI2C
#define MX_I2C_C
#define MX_I2C_SDA 4
#define MX_I2C_SCL 3
#define MX_PWM
#define MX_PWM_CNT 2
#define MX_PWM_TRIS1 trisc
#define MX_PWM_1 2
#define MX_PWM_TRIS2 trisc
#define MX_PWM_2 1
//Functions
#include <system.h>
#pragma CLOCK_FREQ 8000000
//Configuration data
#pragma DATA 0x2007, 0x3ff2
//Internal functions
#include "C:\Program Files\Matrix Multimedia\Flowcode V3\FCD\internals.h"
//Macro function declarations
//Variable declarations
short FCV_CTR;
//LCDDisplay0: //Macro function declarations
void FCD_LCDDisplay0_GetDefines();
void FCD_LCDDisplay0_Start();
void FCD_LCDDisplay0_Clear();
void FCD_LCDDisplay0_PrintASCII(char Character);
void FCD_LCDDisplay0_Command(char in);
void FCD_LCDDisplay0_RawSend(char in, char mask);
void FCD_LCDDisplay0_Cursor(char x, char y);
void FCD_LCDDisplay0_PrintNumber(short Number);
void FCD_LCDDisplay0_PrintString(char* String, char MSZ_String);
//Supplementary defines
//LCDDisplay0: //Macro implementations
void FCD_LCDDisplay0_GetDefines()
{
} //Dummy end of function to allow defines to be added correctly
//component connections
#define LCD_328988_PORT portb
#define LCD_328988_TRIS trisb
#define LCD_328988_BIT0 0
#define LCD_328988_BIT1 1
#define LCD_328988_BIT2 2
#define LCD_328988_BIT3 3
#define LCD_328988_RS 4
#define LCD_328988_E 5
#ifdef _BOOSTC
#define LCD_328988_DELAY delay_10us(10)
#endif
#ifdef _C2C_
#define LCD_328988_DELAY delay_us(100)
#endif
#ifndef LCD_328988_DELAY
#define LCD_328988_DELAY delay_us(100)
#endif
//internal function prototypes
void LCD_328988_RawSend(char nIn, char nMask);
//internal function implementations
void LCD_328988_RawSend(char nIn, char nMask)
{
unsigned char pt;
unsigned char outVal;
outVal = LCD_328988_PORT;
clear_bit(outVal, LCD_328988_BIT0);
clear_bit(outVal, LCD_328988_BIT1);
clear_bit(outVal, LCD_328988_BIT2);
clear_bit(outVal, LCD_328988_BIT3);
clear_bit(outVal, LCD_328988_RS);
clear_bit(outVal, LCD_328988_E);
pt = ((nIn >> 4) & 0x0f);
if (pt & 0x01)
set_bit(outVal, LCD_328988_BIT0);
if (pt & 0x02)
set_bit(outVal, LCD_328988_BIT1);
if (pt & 0x04)
set_bit(outVal, LCD_328988_BIT2);
if (pt & 0x08)
set_bit(outVal, LCD_328988_BIT3);
if (nMask)
set_bit(outVal, LCD_328988_RS);
LCD_328988_PORT = outVal;
LCD_328988_DELAY;
set_bit (LCD_328988_PORT, LCD_328988_E);
LCD_328988_DELAY;
clear_bit (LCD_328988_PORT, LCD_328988_E);
pt = (nIn & 0x0f);
LCD_328988_DELAY;
outVal = LCD_328988_PORT;
clear_bit(outVal, LCD_328988_BIT0);
clear_bit(outVal, LCD_328988_BIT1);
clear_bit(outVal, LCD_328988_BIT2);
clear_bit(outVal, LCD_328988_BIT3);
clear_bit(outVal, LCD_328988_RS);
clear_bit(outVal, LCD_328988_E);
if (pt & 0x01)
set_bit(outVal, LCD_328988_BIT0);
if (pt & 0x02)
set_bit(outVal, LCD_328988_BIT1);
if (pt & 0x04)
set_bit(outVal, LCD_328988_BIT2);
if (pt & 0x08)
set_bit(outVal, LCD_328988_BIT3);
if (nMask)
set_bit(outVal, LCD_328988_RS);
LCD_328988_PORT = outVal;
LCD_328988_DELAY;
set_bit (LCD_328988_PORT, LCD_328988_E);
LCD_328988_DELAY;
clear_bit (LCD_328988_PORT, LCD_328988_E);
LCD_328988_DELAY;
}
// Dummy function to close the defines section off
void LCD_328988_Dummy_Function();
void LCD_328988_Dummy_Function()
{
}
void FCD_LCDDisplay0_Start()
{
clear_bit(LCD_328988_TRIS, LCD_328988_BIT0);
clear_bit(LCD_328988_TRIS, LCD_328988_BIT1);
clear_bit(LCD_328988_TRIS, LCD_328988_BIT2);
clear_bit(LCD_328988_TRIS, LCD_328988_BIT3);
clear_bit(LCD_328988_TRIS, LCD_328988_RS);
clear_bit(LCD_328988_TRIS, LCD_328988_E);
delay_ms(12);
LCD_328988_RawSend(0x33, 0);
delay_ms(2);
LCD_328988_RawSend(0x32, 0);
delay_ms(2);
LCD_328988_RawSend(0x2c, 0);
delay_ms(2);
LCD_328988_RawSend(0x06, 0);
delay_ms(2);
LCD_328988_RawSend(0x0c, 0);
delay_ms(2);
//clear the display
LCD_328988_RawSend(0x01, 0);
delay_ms(2);
LCD_328988_RawSend(0x02, 0);
delay_ms(2);
}
void FCD_LCDDisplay0_Clear()
{
LCD_328988_RawSend(0x01, 0);
delay_ms(2);
LCD_328988_RawSend(0x02, 0);
delay_ms(2);
}
void FCD_LCDDisplay0_PrintASCII(char Character)
{
LCD_328988_RawSend(Character, 0x10);
}
void FCD_LCDDisplay0_Command(char in)
{
LCD_328988_RawSend(in, 0);
delay_ms(2);
}
void FCD_LCDDisplay0_RawSend(char in, char mask)
{
//Error Reading Code For LCD Display::Macro_RawSend
}
void FCD_LCDDisplay0_Cursor(char x, char y)
{
#if (2 == 1)
y=0x80;
#endif
#if (2 == 2)
if (y==0)
y=0x80;
else
y=0xc0;
#endif
#if (2 == 4)
if (y==0)
y=0x80;
else if (y==1)
y=0xc0;
else if (y==2)
y=0x90;
else
y=0xd0;
#endif
LCD_328988_RawSend(y+x, 0);
delay_ms(2);
}
void FCD_LCDDisplay0_PrintNumber(short Number)
{
short tmp_int;
char tmp_byte;
if (Number < 0)
{
LCD_328988_RawSend('-', 0x10);
Number = 0 - Number;
}
tmp_int = Number;
if (Number >= 10000)
{
tmp_byte = tmp_int / 10000;
LCD_328988_RawSend('0' + tmp_byte, 0x10);
while (tmp_byte > 0)
{
tmp_int = tmp_int - 10000;
tmp_byte--;
}
}
if (Number >= 1000)
{
tmp_byte = tmp_int / 1000;
LCD_328988_RawSend('0' + tmp_byte, 0x10);
while (tmp_byte > 0)
{
tmp_int = tmp_int - 1000;
tmp_byte--;
}
}
if (Number >= 100)
{
tmp_byte = tmp_int / 100;
LCD_328988_RawSend('0' + tmp_byte, 0x10);
while (tmp_byte > 0)
{
tmp_int = tmp_int - 100;
tmp_byte--;
}
}
if (Number >= 10)
{
tmp_byte = tmp_int / 10;
LCD_328988_RawSend('0' + tmp_byte, 0x10);
while (tmp_byte > 0)
{
tmp_int = tmp_int - 10;
tmp_byte--;
}
}
LCD_328988_RawSend('0' + tmp_int, 0x10);
}
void FCD_LCDDisplay0_PrintString(char* String, char MSZ_String)
{
char idx;
for (idx=0; idx<MSZ_String; idx++)
{
if (String[idx]==0)
{
break;
}
LCD_328988_RawSend(String[idx], 0x10);
}
}
//Macro implementations
//Supplementary implementations
void main()
{
//Initialisation
adcon1 = 0x07;
//Interrupt initialisation code
option_reg = 0xC0;
//Call Component Macro
//Call Component Macro: LCDDisplay(0)::Start
FCD_LCDDisplay0_Start();
//Delay
//Delay: 1 s
delay_s(1);
//Call Component Macro
//Call Component Macro: LCDDisplay(0)::Cursor(0, 0)
FCD_LCDDisplay0_Cursor(0, 0);
//Call Component Macro
//Call Component Macro: LCDDisplay(0)::PrintASCII("pic 16f877a")
FCD_LCDDisplay0_PrintASCII('p');
FCD_LCDDisplay0_PrintASCII('i');
FCD_LCDDisplay0_PrintASCII('c');
FCD_LCDDisplay0_PrintASCII(' ');
FCD_LCDDisplay0_PrintASCII('1');
FCD_LCDDisplay0_PrintASCII('6');
FCD_LCDDisplay0_PrintASCII('f');
FCD_LCDDisplay0_PrintASCII('8');
FCD_LCDDisplay0_PrintASCII('7');
FCD_LCDDisplay0_PrintASCII('7');
FCD_LCDDisplay0_PrintASCII('a');
mainendloop: goto mainendloop;
}
void interrupt(void)
{
}