#include <LPC214x.h>
#define LED1 10
#define LED2 11
#define Btn1 15
#define GETBIT(var,bit) (((var)>>(bit))&1)
#define SETBIT(var,bit) ((var)|=(1<<(bit)))
#define CLRBIT(var,bit) ((var)&=(~(1<<(bit))))
void Initialize(void);
void feed(void);
void DelayUs(int us);
void DelayMs(int ms);
void DelayS(int se);
int main(void);
int main(void){
char MyDat;
int i,j;
Initialize();
PINSEL0=0x00000000;
IODIR0=0xFFFFFFFF;
CLRBIT(IODIR0,Btn1);
while(1){
CLRBIT(IOPIN0,LED2);
SETBIT(IOPIN0,LED1);
DelayS(1);
SETBIT(IOPIN0,LED2);
CLRBIT(IOPIN0,LED1);
DelayS(1);
}
}
void DelayUs(int us) {
for (; us>0; us--);
}
void DelayMs(int ms) {
for (; ms>0; ms--)
DelayUs(1000);
}
void DelayS(int se) {
for (; se>0; se--)
DelayMs(1000);
}
unsigned char GetPin(unsigned long tPin){
unsigned long tmp;
DelayMs(10);
tmp = IOPIN0 & (1<<tPin);
if(tmp == 0)
return 0;
else
return 1;
}
#define PLOCK 0x400
void Initialize(void) {
// Setting Multiplier and Divider values
PLL0CFG=0x23;
feed();
// Enabling the PLL */
PLL0CON=0x1;
feed();
// Wait for the PLL to lock to set frequency
while(!(PLL0STAT & PLOCK)) ;
// Connect the PLL as the clock source
PLL0CON=0x3;
feed();
// Enabling MAM and setting number of clocks used for Flash memory fetch (4 cclks in this case)
MAMCR=0x2;
MAMTIM=0x4;
// Setting peripheral Clock (pclk) to System Clock (cclk)
VPBDIV=0x1;
}
void feed(void)
{
PLL0FEED=0xAA;
PLL0FEED=0x55;
}
heh the only header i have is from KEIL website:
NXP (founded by Philips) LPC2148
Im not sure i will need anything else but that to create anything i need. If anything ill make custom stuff anyway
void DelayUs(int us) {
int tmp;
for (; us>0; us--);
for(tmp=0;tmp<1000;tmp++); // or for(tmp=1000;tmp>0;tmp--);
}
void DelayMs(int ms) {
for (; ms>0; ms--)
DelayUs(1000);
}
void DelayS(int se) {
for (; se>0; se--)
DelayMs(1000);
}
// *****************************************************************************
// SOFTWARE API DEFINITION FOR Two-wire Interface
// *****************************************************************************
typedef struct _AT91S_TWI {
AT91_REG TWI_CR; // Control Register
AT91_REG TWI_MMR; // Master Mode Register
AT91_REG Reserved0[1]; //
AT91_REG TWI_IADR; // Internal Address Register
AT91_REG TWI_CWGR; // Clock Waveform Generator Register
AT91_REG Reserved1[3]; //
AT91_REG TWI_SR; // Status Register
AT91_REG TWI_IER; // Interrupt Enable Register
AT91_REG TWI_IDR; // Interrupt Disable Register
AT91_REG TWI_IMR; // Interrupt Mask Register
AT91_REG TWI_RHR; // Receive Holding Register
AT91_REG TWI_THR; // Transmit Holding Register
} AT91S_TWI, *AT91PS_TWI;
// -------- TWI_CR : (TWI Offset: 0x0) TWI Control Register --------
#define AT91C_TWI_START ((unsigned int) 0x1 << 0) // (TWI) Send a START Condition
#define AT91C_TWI_STOP ((unsigned int) 0x1 << 1) // (TWI) Send a STOP Condition
#define AT91C_TWI_MSEN ((unsigned int) 0x1 << 2) // (TWI) TWI Master Transfer Enabled
#define AT91C_TWI_MSDIS ((unsigned int) 0x1 << 3) // (TWI) TWI Master Transfer Disabled
#define AT91C_TWI_SWRST ((unsigned int) 0x1 << 7) // (TWI) Software Reset
// -------- TWI_MMR : (TWI Offset: 0x4) TWI Master Mode Register --------
#define AT91C_TWI_IADRSZ ((unsigned int) 0x3 << 8) // (TWI) Internal Device Address Size
#define AT91C_TWI_IADRSZ_NO ((unsigned int) 0x0 << 8) // (TWI) No internal device address
#define AT91C_TWI_IADRSZ_1_BYTE ((unsigned int) 0x1 << 8) // (TWI) One-byte internal device address
#define AT91C_TWI_IADRSZ_2_BYTE ((unsigned int) 0x2 << 8) // (TWI) Two-byte internal device address
#define AT91C_TWI_IADRSZ_3_BYTE ((unsigned int) 0x3 << 8) // (TWI) Three-byte internal device address
#define AT91C_TWI_MREAD ((unsigned int) 0x1 << 12) // (TWI) Master Read Direction
#define AT91C_TWI_DADR ((unsigned int) 0x7F << 16) // (TWI) Device Address
// -------- TWI_CWGR : (TWI Offset: 0x10) TWI Clock Waveform Generator Register --------
#define AT91C_TWI_CLDIV ((unsigned int) 0xFF << 0) // (TWI) Clock Low Divider
#define AT91C_TWI_CHDIV ((unsigned int) 0xFF << 8) // (TWI) Clock High Divider
#define AT91C_TWI_CKDIV ((unsigned int) 0x7 << 16) // (TWI) Clock Divider
// -------- TWI_SR : (TWI Offset: 0x20) TWI Status Register --------
#define AT91C_TWI_TXCOMP ((unsigned int) 0x1 << 0) // (TWI) Transmission Completed
#define AT91C_TWI_RXRDY ((unsigned int) 0x1 << 1) // (TWI) Receive holding register ReaDY
#define AT91C_TWI_TXRDY ((unsigned int) 0x1 << 2) // (TWI) Transmit holding register ReaDY
#define AT91C_TWI_OVRE ((unsigned int) 0x1 << 6) // (TWI) Overrun Error
#define AT91C_TWI_UNRE ((unsigned int) 0x1 << 7) // (TWI) Underrun Error
#define AT91C_TWI_NACK ((unsigned int) 0x1 << 8) // (TWI) Not Acknowledged
// -------- TWI_IER : (TWI Offset: 0x24) TWI Interrupt Enable Register --------
// -------- TWI_IDR : (TWI Offset: 0x28) TWI Interrupt Disable Register --------
// -------- TWI_IMR : (TWI Offset: 0x2c) TWI Interrupt Mask Register --------
#include <LPC214x.h>
#define GETBIT(var,bit) (((var)>>(bit))&1)
#define SETBIT(var,bit) ((var)|=(1<<(bit)))
#define CLRBIT(var,bit) ((var)&=(~(1<<(bit))))
#define LCDP IOPIN1
#define CS 21
#define DC 22
#define SCL 23
#define SDO 24
#define RST 25
#define LED1 10
#define BTN 15
/*
LCD | DESC | PIN-COLOR WIRE
--------------------------------------------
--------------------------------------------
2 | CS | 1.LIGHT BLUE
--------------------------------------------
4 | D/C | 2.ORANGE
--------------------------------------------
5 | SCL | 5.BLUE
--------------------------------------------
13 | DATA | 6.WHITE - BLACK
--------------------------------------------
14 | RESET | 7.WHITE - LIGHT BLUE
--------------------------------------------
*/
int main(void);
void Initialize(void);
void feed(void);
void DelayUs(int us);
void DelayMs(int ms);
void DelayS(int se);
void CLS(void);
void LCD_Init(void);
void LCD_Reset(void);
void SendByte(unsigned char data);
void LCD_Send(unsigned char cmd, unsigned char type);
void LCDChar(unsigned char letter,unsigned char font,unsigned char style,unsigned char top, unsigned char left);
void LCDString(const char *str,unsigned char font,unsigned char style,unsigned char top, unsigned char left);
const char Font5x7 [] = {
0x00,0x00,0x00,0x00,0x00, // 20 space
0x00,0x00,0x5f,0x00,0x00, // 21 !
0x00,0x07,0x00,0x07,0x00, // 22 "
0x14,0x7f,0x14,0x7f,0x14, // 23 #
0x24,0x2a,0x7f,0x2a,0x12, // 24 $
0x23,0x13,0x08,0x64,0x62, // 25 %
0x36,0x49,0x55,0x22,0x50, // 26 &
0x00,0x05,0x03,0x00,0x00, // 27 '
0x00,0x1c,0x22,0x41,0x00, // 28 (
0x00,0x41,0x22,0x1c,0x00, // 29 )
0x14,0x08,0x3e,0x08,0x14, // 2a *
0x08,0x08,0x3e,0x08,0x08, // 2b +
0x00,0x50,0x30,0x00,0x00, // 2c ,
0x08,0x08,0x08,0x08,0x08, // 2d -
0x00,0x60,0x60,0x00,0x00, // 2e .
0x20,0x10,0x08,0x04,0x02, // 2f /
0x3e,0x51,0x49,0x45,0x3e, // 30 0
0x00,0x42,0x7f,0x40,0x00, // 31 1
0x42,0x61,0x51,0x49,0x46, // 32 2
0x21,0x41,0x45,0x4b,0x31, // 33 3
0x18,0x14,0x12,0x7f,0x10, // 34 4
0x27,0x45,0x45,0x45,0x39, // 35 5
0x3c,0x4a,0x49,0x49,0x30, // 36 6
0x01,0x71,0x09,0x05,0x03, // 37 7
0x36,0x49,0x49,0x49,0x36, // 38 8
0x06,0x49,0x49,0x29,0x1e, // 39 9
0x00,0x36,0x36,0x00,0x00, // 3a :
0x00,0x56,0x36,0x00,0x00, // 3b ;
0x08,0x14,0x22,0x41,0x00, // 3c <
0x14,0x14,0x14,0x14,0x14, // 3d =
0x00,0x41,0x22,0x14,0x08, // 3e >
0x02,0x01,0x51,0x09,0x06, // 3f ?
0x32,0x49,0x79,0x41,0x3e, // 40 @
0x7e,0x11,0x11,0x11,0x7e, // 41 A
0x7f,0x49,0x49,0x49,0x36, // 42 B
0x3e,0x41,0x41,0x41,0x22, // 43 C
0x7f,0x41,0x41,0x22,0x1c, // 44 D
0x7f,0x49,0x49,0x49,0x41, // 45 E
0x7f,0x09,0x09,0x09,0x01, // 46 F
0x3e,0x41,0x49,0x49,0x7a, // 47 G
0x7f,0x08,0x08,0x08,0x7f, // 48 H
0x00,0x41,0x7f,0x41,0x00, // 49 I
0x20,0x40,0x41,0x3f,0x01, // 4a J
0x7f,0x08,0x14,0x22,0x41, // 4b K
0x7f,0x40,0x40,0x40,0x40, // 4c L
0x7f,0x02,0x0c,0x02,0x7f, // 4d M
0x7f,0x04,0x08,0x10,0x7f, // 4e N
0x3e,0x41,0x41,0x41,0x3e, // 4f O
0x7f,0x09,0x09,0x09,0x06, // 50 P
0x3e,0x41,0x51,0x21,0x5e, // 51 Q
0x7f,0x09,0x19,0x29,0x46, // 52 R
0x46,0x49,0x49,0x49,0x31, // 53 S
0x01,0x01,0x7f,0x01,0x01, // 54 T
0x3f,0x40,0x40,0x40,0x3f, // 55 U
0x1f,0x20,0x40,0x20,0x1f, // 56 V
0x3f,0x40,0x38,0x40,0x3f, // 57 W
0x63,0x14,0x08,0x14,0x63, // 58 X
0x07,0x08,0x70,0x08,0x07, // 59 Y
0x61,0x51,0x49,0x45,0x43, // 5a Z
0x00,0x7f,0x41,0x41,0x00, // 5b [
0x02,0x04,0x08,0x10,0x20, // 5c 55
0x00,0x41,0x41,0x7f,0x00, // 5d ]
0x04,0x02,0x01,0x02,0x04, // 5e ^
0x40,0x40,0x40,0x40,0x40, // 5f _
0x00,0x01,0x02,0x04,0x00, // 60 `
0x20,0x54,0x54,0x54,0x78, // 61 a
0x7f,0x48,0x44,0x44,0x38, // 62 b
0x38,0x44,0x44,0x44,0x20, // 63 c
0x38,0x44,0x44,0x48,0x7f, // 64 d
0x38,0x54,0x54,0x54,0x18, // 65 e
0x08,0x7e,0x09,0x01,0x02, // 66 f
0x0c,0x52,0x52,0x52,0x3e, // 67 g
0x7f,0x08,0x04,0x04,0x78, // 68 h
0x00,0x44,0x7d,0x40,0x00, // 69 i
0x20,0x40,0x44,0x3d,0x00, // 6a j
0x7f,0x10,0x28,0x44,0x00, // 6b k
0x00,0x41,0x7f,0x40,0x00, // 6c l
0x7c,0x04,0x18,0x04,0x78, // 6d m
0x7c,0x08,0x04,0x04,0x78, // 6e n
0x38,0x44,0x44,0x44,0x38, // 6f o
0x7c,0x14,0x14,0x14,0x08, // 70 p
0x08,0x14,0x14,0x18,0x7c, // 71 q
0x7c,0x08,0x04,0x04,0x08, // 72 r
0x48,0x54,0x54,0x54,0x20, // 73 s
0x04,0x3f,0x44,0x40,0x20, // 74 t
0x3c,0x40,0x40,0x20,0x7c, // 75 u
0x1c,0x20,0x40,0x20,0x1c, // 76 v
0x3c,0x40,0x30,0x40,0x3c, // 77 w
0x44,0x28,0x10,0x28,0x44, // 78 x
0x0c,0x50,0x50,0x50,0x3c, // 79 y
0x44,0x64,0x54,0x4c,0x44, // 7a z
0x00,0x08,0x36,0x41,0x00, // 7b {
0x00,0x00,0x7f,0x00,0x00, // 7c |
0x00,0x41,0x36,0x08,0x00, // 7d }
0x10,0x08,0x08,0x10,0x08, // 7e ~
0x78,0x46,0x41,0x46,0x78}; // 7f ¦
const char Font8x8[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 , // ASCII - 32
0x00,0x00,0x00,0x5F,0x5F,0x00,0x00,0x00 , // ASCII - 33
0x00,0x00,0x03,0x07,0x00,0x07,0x03,0x00 , // ASCII - 34
0x00,0x10,0x74,0x1C,0x77,0x1C,0x17,0x04 , // ASCII - 35
0x00,0x24,0x2E,0x2A,0x7F,0x2A,0x3A,0x10 , // ASCII - 36
0x00,0x4C,0x6A,0x76,0x1A,0x6A,0x56,0x33 , // ASCII - 37
0x00,0x30,0x7A,0x4F,0x5D,0x37,0x7A,0x48 , // ASCII - 38
0x00,0x00,0x04,0x07,0x03,0x00,0x00,0x00 , // ASCII - 39
0x00,0x00,0x00,0x1C,0x3E,0x63,0x41,0x00 , // ASCII - 40
0x00,0x00,0x41,0x63,0x3E,0x1C,0x00,0x00 , // ASCII - 41
0x00,0x08,0x2A,0x3E,0x1C,0x3E,0x2A,0x08 , // ASCII - 42
0x00,0x08,0x08,0x3E,0x3E,0x08,0x08,0x00 , // ASCII - 43
0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00 , // ASCII - 44
0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00 , // ASCII - 45
0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00 , // ASCII - 46
0x00,0x60,0x30,0x18,0x0C,0x06,0x03,0x01 , // ASCII - 47
0x00,0x1C,0x3E,0x61,0x43,0x3E,0x1C,0x00 , // ASCII - 48
0x00,0x00,0x44,0x7F,0x7F,0x40,0x00,0x00 , // ASCII - 49
0x00,0x46,0x67,0x71,0x59,0x4F,0x66,0x00 , // ASCII - 50
0x00,0x22,0x63,0x49,0x4D,0x7F,0x32,0x00 , // ASCII - 51
0x00,0x18,0x1C,0x52,0x7F,0x7F,0x50,0x00 , // ASCII - 52
0x00,0x2F,0x6F,0x45,0x45,0x7D,0x39,0x00 , // ASCII - 53
0x00,0x3C,0x7E,0x4B,0x49,0x79,0x30,0x00 , // ASCII - 54
0x00,0x07,0x43,0x71,0x7D,0x0F,0x03,0x00 , // ASCII - 55
0x00,0x36,0x7F,0x4D,0x59,0x7F,0x36,0x00 , // ASCII - 56
0x00,0x06,0x4F,0x49,0x69,0x3F,0x1E,0x00 , // ASCII - 57
0x00,0x00,0x00,0x66,0x66,0x00,0x00,0x00 , // ASCII - 58
0x00,0x00,0x00,0x66,0x66,0x00,0x00,0x00 , // ASCII - 59
0x00,0x00,0x08,0x1C,0x36,0x63,0x41,0x00 , // ASCII - 60
0x00,0x14,0x14,0x14,0x14,0x14,0x14,0x00 , // ASCII - 61
0x00,0x00,0x41,0x63,0x36,0x1C,0x08,0x00 , // ASCII - 62
0x00,0x02,0x07,0x51,0x59,0x0F,0x06,0x00 , // ASCII - 63
0x00,0x3E,0x41,0x5D,0x55,0x5D,0x51,0x1E , // ASCII - 64
0x00,0x40,0x70,0x1D,0x17,0x1F,0x78,0x60 , // ASCII - 65
0x00,0x41,0x7F,0x7F,0x49,0x4F,0x7E,0x30 , // ASCII - 66
0x00,0x1C,0x3E,0x63,0x41,0x41,0x42,0x27 , // ASCII - 67
0x00,0x41,0x7F,0x7F,0x41,0x63,0x3E,0x1C , // ASCII - 68
0x00,0x41,0x7F,0x7F,0x49,0x5D,0x41,0x63 , // ASCII - 69
0x00,0x41,0x7F,0x7F,0x49,0x1D,0x01,0x03 , // ASCII - 70
0x00,0x1C,0x3E,0x63,0x41,0x51,0x72,0x77 , // ASCII - 71
0x00,0x7F,0x7F,0x08,0x08,0x7F,0x7F,0x00 , // ASCII - 72
0x00,0x00,0x41,0x7F,0x7F,0x41,0x00,0x00 , // ASCII - 73
0x00,0x30,0x70,0x41,0x41,0x7F,0x3F,0x01 , // ASCII - 74
0x00,0x7F,0x7F,0x08,0x1C,0x77,0x63,0x41 , // ASCII - 75
0x00,0x41,0x7F,0x7F,0x41,0x40,0x60,0x70 , // ASCII - 76
0x00,0x7F,0x7E,0x0C,0x18,0x0C,0x7E,0x7F , // ASCII - 77
0x00,0x7F,0x7E,0x0C,0x18,0x30,0x7F,0x7F , // ASCII - 78
0x00,0x1C,0x3E,0x63,0x41,0x63,0x3E,0x1C , // ASCII - 79
0x00,0x41,0x7F,0x7F,0x49,0x09,0x0F,0x06 , // ASCII - 80
0x00,0x1C,0x3E,0x63,0x51,0x63,0x3E,0x1C , // ASCII - 81
0x00,0x7F,0x7F,0x09,0x19,0x7F,0x66,0x40 , // ASCII - 82
0x00,0x66,0x6F,0x4D,0x59,0x7B,0x33,0x00 , // ASCII - 83
0x00,0x03,0x41,0x7F,0x7F,0x41,0x03,0x00 , // ASCII - 84
0x00,0x3F,0x7F,0x40,0x40,0x40,0x7F,0x3F , // ASCII - 85
0x00,0x03,0x0F,0x3D,0x70,0x1D,0x07,0x01 , // ASCII - 86
0x00,0x0F,0x7F,0x30,0x1C,0x30,0x7F,0x0F , // ASCII - 87
0x00,0x63,0x77,0x1C,0x1C,0x77,0x63,0x00 , // ASCII - 88
0x01,0x03,0x47,0x7C,0x78,0x47,0x03,0x01 , // ASCII - 89
0x00,0x67,0x73,0x59,0x4D,0x67,0x73,0x00 , // ASCII - 90
0x00,0x00,0x00,0x7F,0x7F,0x41,0x41,0x00 , // ASCII - 91
0x00,0x01,0x03,0x06,0x0C,0x18,0x30,0x60 , // ASCII - 92
0x00,0x00,0x41,0x41,0x7F,0x7F,0x00,0x00 , // ASCII - 93
0x00,0x00,0x04,0x06,0x03,0x06,0x04,0x00 , // ASCII - 94
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 , // ASCII - 95
0x00,0x00,0x01,0x03,0x06,0x04,0x00,0x00 , // ASCII - 96
0x00,0x68,0x6C,0x54,0x54,0x3C,0x78,0x40 , // ASCII - 97
0x00,0x41,0x7F,0x3F,0x6C,0x44,0x7C,0x38 , // ASCII - 98
0x00,0x38,0x7C,0x44,0x44,0x6C,0x2C,0x00 , // ASCII - 99
0x00,0x38,0x7C,0x44,0x49,0x3F,0x7F,0x40 , // ASCII - 100
0x00,0x38,0x7C,0x54,0x54,0x5C,0x58,0x00 , // ASCII - 101
0x00,0x00,0x48,0x7E,0x7F,0x49,0x0B,0x02 , // ASCII - 102
0x00,0x48,0x7C,0x34,0x34,0x2C,0x68,0x44 , // ASCII - 103
0x00,0x41,0x7F,0x7F,0x08,0x04,0x7C,0x78 , // ASCII - 104
0x00,0x00,0x44,0x7D,0x7D,0x40,0x00,0x00 , // ASCII - 105
0x00,0x60,0x60,0x04,0x7D,0x7D,0x00,0x00 , // ASCII - 106
0x00,0x41,0x7F,0x7F,0x10,0x78,0x6C,0x44 , // ASCII - 107
0x00,0x00,0x41,0x7F,0x7F,0x40,0x00,0x00 , // ASCII - 108
0x00,0x7C,0x7C,0x0C,0x78,0x0C,0x7C,0x78 , // ASCII - 109
0x00,0x44,0x7C,0x7C,0x08,0x04,0x7C,0x78 , // ASCII - 110
0x00,0x38,0x7C,0x44,0x44,0x7C,0x38,0x00 , // ASCII - 111
0x00,0x04,0x7C,0x78,0x24,0x24,0x3C,0x18 , // ASCII - 112
0x00,0x18,0x3C,0x24,0x24,0x78,0x7C,0x00 , // ASCII - 113
0x00,0x44,0x7C,0x78,0x4C,0x04,0x1C,0x18 , // ASCII - 114
0x00,0x48,0x5C,0x5C,0x74,0x74,0x24,0x00 , // ASCII - 115
0x00,0x00,0x04,0x3E,0x7F,0x44,0x24,0x00 , // ASCII - 116
0x00,0x3C,0x7C,0x40,0x40,0x3C,0x7C,0x40 , // ASCII - 117
0x00,0x04,0x1C,0x3C,0x60,0x30,0x1C,0x04 , // ASCII - 118
0x00,0x1C,0x7C,0x30,0x1C,0x30,0x7C,0x1C , // ASCII - 119
0x00,0x44,0x6C,0x3C,0x10,0x78,0x6C,0x44 , // ASCII - 120
0x00,0x44,0x4C,0x1C,0x70,0x64,0x1C,0x0C , // ASCII - 121
0x00,0x4C,0x64,0x74,0x5C,0x4C,0x64,0x00 , // ASCII - 122
0x00,0x08,0x08,0x3E,0x77,0x41,0x41,0x00 , // ASCII - 123
0x00,0x00,0x00,0x7F,0x7F,0x00,0x00,0x00 , // ASCII - 124
0x00,0x41,0x41,0x77,0x3E,0x08,0x08,0x00 , // ASCII - 125
0x00,0x02,0x01,0x01,0x03,0x02,0x02,0x01 , // ASCII - 126
0x00,0x60,0x78,0x4E,0x47,0x5E,0x78,0x60}; // ASCII - 127
#define None 0x00
#define Strike 0x10
#define DblStrike 0x24
#define Underline 0x80
#define Overline 0x01
int main(void){
char MyDat;
int i,j;
Initialize();
PINSEL0=0x00000000;
IODIR0=0xFFFFFFFF;
PINSEL1=0x00000000;
IODIR1=0xFFFFFFFF;
CLRBIT(IODIR0,BTN);
LCD_Init();
SETBIT(IOPIN0,LED1);
CLS();
LCDString("AtomSoftTech ",0,None,0,0);
LCDString(" .info ",0,None,1,0);
LCDString(" Nokia 7110 LCD ",0,None,3,0);
LCDString("Author:",1,Underline,5,0);
LCDString("Jason Lopez ",0,None,7,0);
while(GETBIT(IOPIN0,BTN));
DelayMs(10);
CLS();
LCDString("Page 2 ",0,None,0,0);
while(GETBIT(IOPIN0,BTN));
DelayMs(10);
while(1){
}
}
void DelayUs(int us) {
int tmp;
for (; us>0; us--);
for(tmp=0;tmp<1000;tmp++); // or for(tmp=1000;tmp>0;tmp--);
}
void DelayMs(int ms) {
for (; ms>0; ms--)
DelayUs(1000);
}
void DelayS(int se) {
for (; se>0; se--)
DelayMs(1000);
}
unsigned char GetPin(unsigned long tPin){
unsigned long tmp;
DelayMs(10);
tmp = IOPIN0 & (1<<tPin);
if(tmp == 0)
return 0;
else
return 1;
}
#define PLOCK 0x400
void Initialize(void) {
// Setting Multiplier and Divider values
PLL0CFG=0x23;
feed();
// Enabling the PLL */
PLL0CON=0x1;
feed();
// Wait for the PLL to lock to set frequency
while(!(PLL0STAT & PLOCK)) ;
// Connect the PLL as the clock source
PLL0CON=0x3;
feed();
// Enabling MAM and setting number of clocks used for Flash memory fetch (4 cclks in this case)
MAMCR=0x2;
MAMTIM=0x4;
// Setting peripheral Clock (pclk) to System Clock (cclk)
VPBDIV=0x01;
}
void feed(void)
{
PLL0FEED=0xAA;
PLL0FEED=0x55;
}
void LCD_Init(void){
SETBIT(IOPIN0,BTN);
SETBIT(LCDP,DC);
DelayMs(8);
LCD_Reset();
LCD_Send(0xA6,0); //Display: Normal
LCD_Send(0xA3,0); //LCD Bias Settings: 1/7
LCD_Send(0xA1,0); //ADC Selection: Reverse
LCD_Send(0xC0,0); //Common Output: Normal Direction
//LCD_Send(0xC8,0); //Common Output: Upside Down
LCD_Send(0x22,0); //Set the V5 output Voltage
LCD_Send(0x81,0); //Set Electronic Volume Register
LCD_Send(0x2E,0); //Power Controller Set: Booster circuit: ON/Voltage regulator circuit: ON/Voltage follower circuit: OFF
LCD_Send(0x2F,0); //Power Controller Set: Voltage follower circuit: ON
LCD_Send(0xE3,0); //Non-OPeration Command
LCD_Send(0x40,0); //Set the start line
LCD_Send(0xAF,0); //LCD On
LCD_Send(0xA5,0); //Display All Points: ON
DelayMs(17);
LCD_Send(0xA4,0); //Display All Points: NORMAL
}
void CLS(void){
unsigned char i,x;
unsigned char line;
line = 0xB0;
for(x=0;x<9;x++){
LCD_Send(line,0);
LCD_Send(17,0);
LCD_Send(2,0);
for(i=0;i<0x60;i++){
LCD_Send(0x00,1);
}
line++;
}
}
void SendByte(unsigned char data){
char x;
for(x=0;x<8;x++){
CLRBIT(LCDP,SCL);
CLRBIT(LCDP,SDO);
if(data & 0x80)
SETBIT(LCDP,SDO);
SETBIT(LCDP,SCL);
data <<= 1;
}
}
void LCD_Send(unsigned char cmd, unsigned char type){
if(type){
SETBIT(LCDP,DC);
} else {
CLRBIT(LCDP,DC);
}
CLRBIT(LCDP,CS);
SendByte(cmd);
SETBIT(LCDP,CS);
}
void LCD_Reset(void){
SETBIT(LCDP,CS);
DelayMs(8);
SETBIT(LCDP,RST);
DelayMs(8);
}
void LCDChar(unsigned char letter,unsigned char font,unsigned char style,unsigned char top, unsigned char left){
unsigned char myData,x;
unsigned char leftH,leftL;
top += 0xB0;
left += 18;
leftH = (left >> 4) | 0x10 ;
leftL = left & 0x0F ;
LCD_Send(top,0); //Page 0 (0xBx (x = page))
LCD_Send(leftH,0); //Column Upper Nybble (0x1x) (x = upper Nybble)
LCD_Send(leftL,0); //Column Lower Nybble (0x0x) (x = upper Nybble)
letter -= 0x20;
if(font){
for(x=0;x<8;x++){
myData = Font8x8[((letter*8) + x)] | style;
LCD_Send(myData,1);
}
} else {
for(x=0;x<5;x++){
myData = Font5x7[((letter*5) + x)] | style;
LCD_Send(myData,1);
}
}
LCD_Send((0|style),1); //Spacer
}
void LCDString(const char *str,unsigned char font,unsigned char style,unsigned char top, unsigned char left){
while(*str != 0){
LCDChar(*str++, font, style, top, left);
if(font)
left += 9;
else
left += 6;
}
}
It looks too dark on mine, and apparently it's because FF 3.5 uses colour profiles, but doesn't support ICC4. Check one of the pictures out in another browser like IE and tell me if it looks the same, would ya.heh... firefox on my side shows them well
by the way where can i buy a 20 pin IDC cable like that?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?