Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

CCSC , LCD with dspic33f

Status
Not open for further replies.

nofre

Newbie level 4
Joined
Feb 2, 2007
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
ibov2010@yahoo.com
Activity points
1,460
lcd_lib_4bit.c

i write an example to display on my LCD 16x2, use 4bits mode, only PortD
use the lib for LCD :

#include <stddef.h>

#define LCD_RS PIN_D5
#define LCD_RW PIN_D4
#define LCD_EN PIN_D13

#define LCD_D4 PIN_D1
#define LCD_D5 PIN_D2
#define LCD_D6 PIN_D3
#define LCD_D7 PIN_D12

// misc display defines-
#define Line_1 0x80
#define Line_2 0xC0
#define Clear_Scr 0x01

// prototype statements
#separate void LCD_Init ( void );// ham khoi tao LCD
#separate void LCD_SetPosition ( unsigned int cX );
#separate void LCD_PutChar ( unsigned int cX );
#separate void LCD_PutCmd ( unsigned int cX) ;
#separate void LCD_PulseEnable ( void );
#separate void LCD_SetData ( unsigned int cX );


#use standard_io (C)
#use standard_io (D)

//khoi tao LCD**********************************************
# void LCD_Init ( void )
{
LCD_SetData ( 0x00 );
output_low ( LCD_RW );
delay_ms(50); /* wait enough time after Vdd rise >> 15ms */
output_low ( LCD_RS );
LCD_SetData ( 0x03 ); /* init with specific nibbles to start 4-bit mode */
LCD_PulseEnable();
LCD_PulseEnable();
LCD_PulseEnable();
LCD_SetData ( 0x02 ); /* set 4-bit interface */
LCD_PulseEnable(); /* send dual nibbles hereafter, MSN first */
LCD_PutCmd ( 0x2C ); /* function set (all lines, 5x7 characters) */
LCD_PutCmd ( 0x0C ); /* display ON, cursor off, no blink */
LCD_PutCmd ( 0x06 ); /* entry mode set, increment & scroll left */
LCD_PutCmd ( 0x01 ); /* clear display */
}

# void LCD_SetPosition ( unsigned int cX )
{
/* this subroutine works specifically for 4-bit Port A */
LCD_SetData ( swap ( cX ) | 0x08 );
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
}

# void LCD_PutChar ( unsigned int cX )
{
output_high ( LCD_RS );
LCD_PutCmd( cX );
output_low ( LCD_RS );
}

# void LCD_PutCmd ( unsigned int cX )
{
LCD_SetData ( swap ( cX ) ); /* send high nibble */
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) ); /* send low nibble */
LCD_PulseEnable();
}
# void LCD_PulseEnable ( void )
{
output_high ( LCD_EN );
delay_us ( 3 ); // was 10
output_low ( LCD_EN );
delay_ms ( 3 ); // was 5
}

# void LCD_SetData ( unsigned int cX )
{
output_bit ( LCD_D4, cX & 0x01 );
output_bit ( LCD_D5, cX & 0x02 );
output_bit ( LCD_D6, cX & 0x04 );
output_bit ( LCD_D7, cX & 0x08 );
}

//----------------------------------------------------------------------
//---------------------------------------------------------------------

And then the main:

#include "C:\CCSC\main.h"
#include "C:\CCSC\lcd_lib_4bit.c"

void main()
{
char V2[]="I Bet On Victory";
CHAR CONST SS[9]="QICKER!";
int8 i;
LCD_init();
LCD_PutCmd(0x01);
LCD_PutCmd(line_1);
LCD_PutChar(SS)
while (1) {
LCD_PutCmd(line_2);
for(i=0;i<16;i++)
{
LCD_PutChar(V2);
delay_ms(100);
}

}
}

i use PCWHD 4.057 , and nothing happen on my LCD !:cry:
is there any big mistake ? i'm too new at CCSC&dspic also , plz help
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top