i just have a little problem understanding some lines in CCS C code that i have for a sphygmomanometer project & i'm not sure if i actually wired the pic16f877a (with the LCD) correctly or not ..
My reasoning was as follows:
#define lcd_e1 pin_d7 => i wired the "Enable" LCD pin to the pic pin 30 (RD7/PSP7)
#define lcd_rs1 pin_d6 => i wired the "Register Select" LCD pin to pic pin 29 (RD6/PSP6)
#define lcd_port output_b => i wired the LCD's Data pins (DB0,DB1,DB2, ... DB7) to the pic's (pin 33,pin34,pin35,...pin40) in order (which represent RB0 to RB7)
putcmd_lcd(0x38);
// sending the 0X38 to the LCD means :
( Function Set: 8bit, 2Line, 5x7 Dots ) and that's exactly the reason why i wired the whole 8 lines (and not jut 4) because i think we're using the 8 bit mode of operation .
* these are the lines that i couldn't understand :
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
do i have to wire the pins C6 & C7 ??
#define lcd_direction set_tris_b
#define lcd_command set_tris_c
and the function : lcd_port()
i did read the CCS C manual but i couldn't figure out what their actual purpose is ?
i'm new at this so please bear with me (and excuse my poor english,it's not my native language).. any help at all would be much appreciated, Thanks in advance .
Code :
My reasoning was as follows:
#define lcd_e1 pin_d7 => i wired the "Enable" LCD pin to the pic pin 30 (RD7/PSP7)
#define lcd_rs1 pin_d6 => i wired the "Register Select" LCD pin to pic pin 29 (RD6/PSP6)
#define lcd_port output_b => i wired the LCD's Data pins (DB0,DB1,DB2, ... DB7) to the pic's (pin 33,pin34,pin35,...pin40) in order (which represent RB0 to RB7)
putcmd_lcd(0x38);
// sending the 0X38 to the LCD means :
( Function Set: 8bit, 2Line, 5x7 Dots ) and that's exactly the reason why i wired the whole 8 lines (and not jut 4) because i think we're using the 8 bit mode of operation .
* these are the lines that i couldn't understand :
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
do i have to wire the pins C6 & C7 ??
#define lcd_direction set_tris_b
#define lcd_command set_tris_c
and the function : lcd_port()
i did read the CCS C manual but i couldn't figure out what their actual purpose is ?
i'm new at this so please bear with me (and excuse my poor english,it's not my native language).. any help at all would be much appreciated, Thanks in advance .
Code :
Rich (BB code):
#include<16f877a.h>
#fuses hs,nowdt, noprotect, nolvp
#use delay(clock=10000000)
#include<math.h>
#include<string.h>
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#define lcd_e1 pin_d7
#define lcd_rs1 pin_d6
#define lcd_port output_b
#define lcd_direction set_tris_b
#define lcd_command set_tris_c
int mmc_init();
int mmc_response(unsigned char response);
int mmc_write_block(unsigned long block_number);
void init_lcd();//preparation de pic pour lcd
void putdata_lcd(int valued);
void erase_lcd();
void putcmd_lcd(int valuec);
void goto_lcd(int x, int y);
void put_string_lcd(char v[16]);
/* Initialises the MMC into SPI mode and sets block size, returns 0 on success */
......
/***************/
void init_lcd()
{putcmd_lcd(0x38);
delay_ms(6);
putcmd_lcd(0x38);
delay_ms(6);
putcmd_lcd(0x38);
delay_ms(6);
putcmd_lcd(0x01); //reset
delay_ms(6);
putcmd_lcd(0x06); //increment
delay_ms(6);
putcmd_lcd(0x0c);
delay_ms(6);}
void putdata_lcd(int valued)
{lcd_port(valued);
output_high(lcd_rs1); //data
output_high(lcd_e1);
delay_ms(1);
output_low(lcd_e1);
delay_ms(6);
output_low(lcd_rs1); //command
}
void erase_lcd()
{putcmd_lcd(0x01);}
void putcmd_lcd(int valuec)
{lcd_port(valuec);
output_low(lcd_rs1);
output_high(lcd_e1);
delay_ms(1);
output_low(lcd_e1);
delay_ms(6);}
void goto_lcd(int x, int y)
{ if (y==1)
{putcmd_lcd(0x80 + x);}
if (y==2)
{putcmd_lcd(0xc0 + x);}}
void put_string_lcd(char v[16])
{long i;
for(i=0;i<=strlen(v);i++)
putdata_lcd(v);}