PIC C, Serial LCD Routines, CCS PCW Compiler PDF
PIC C, Serial LCD Routines, CCS PCW Compiler PDF
PIC C, Serial LCD Routines, CCS PCW Compiler PDF
#case
#include <16F84.h>
#include <string.h>
#include <defs_f84.h>
// LCD routines
void delay_ms(long t);
void delay_10us(int t);
void lcd_init(void);
void out_RAM_str(int *s);
void lcd_hex_byte(int val);
void lcd_dec_byte(int val, int digits);
int num_to_char(int val);
void lcd_char(int ch);
void lcd_new_line(void);
main()
{
byte s[15];
while(1)
{
lcd_init();
strcpy(s, "Morgan State");
// note that CONST string is copied to RAM string
out_RAM_str(s);
lcd_new_line();
strcpy(s, "University");
out_RAM_str(s);
lcd_new_line();
lcd_hex_byte(254); // display FE
lcd_char(' ');
lcd_dec_byte(192, 3); // display 192
delay_ms(500);
}
}
void delay_10us(int t)
{
#asm
BCF STATUS, RP0
DELAY_10US_1:
CLRWDT
NOP
NOP
NOP
NOP
NOP
NOP
DECFSZ t, F
GOTO DELAY_10US_1
#endasm
}
#asm
BCF STATUS, RP0
MOVLW 9
MOVWF n
BCF STATUS, C
LCD_CHAR_1:
BTFSS STATUS, C
BSF PORTA, TxData
BTFSC STATUS, C
BCF PORTA, TxData
MOVLW 32
MOVWF dly
LCD_CHAR_2:
DECFSZ dly, F
GOTO LCD_CHAR_2
RRF ch, F
DECFSZ n, F
GOTO LCD_CHAR_1
LCD_CHAR_3:
DECFSZ dly, F
GOTO LCD_CHAR_3
CLRWDT
#endasm
}
void out_RAM_str(int s)
{
while(*s)
{
lcd_char(*s);
++s;
}
}
d=val % 10;
ch=num_to_char(d);
lcd_char(ch);
}