Jump to content

Recommended Posts

Hello everyone!:( I just wanna ask for help about displaying characters on 2x16 LCD.

 

In CCS, this is their way of put to characters on LCD:

 

// Declare variables

int i=20;

int j=50;

 

// put "Display: 20 50" on LCD--------

printf(lcd_putc,"Display: %u %u", i, j);

 

I don't know how to do it to boostc..............

Link to post
Share on other sites

jelodavid,

 

The SourceBoost installation includes an LCD template library.

 

#include <system.h>
#include <icd2.h> // only required if using ICD2

////////////////////////////////////////////////////////////////////////////
// LCD template arguments - defines how the LCD is connected to the PIC
////////////////////////////////////////////////////////////////////////////
// These must be define before template header file is included
// Remember when using LCD in 4 bit mode you must connect to the LCDs DB4-DB7 pin
//
// Using this code under SourceBoost simulator (for PIC16F877), configure the LCD 
// plugin as follows:
// RS  to RA3
// R/W to RA2
// E   to RA1
// DB0 to None
// DB1 to None
// DB2 to None
// DB3 to None
// DB4 to RD0
// DB5 to RD1
// DB6 to RD2
// DB7 to RD3
//
// These setting are correct for PICDEM2 PLUS board with PIC16F877 or PIC18F452 target!
#define LCD_ARGS     1,    /* Interface type: mode 0 = 8bit, 1 = 4bit(low nibble), 2 = 4bit(upper nibble) */ \
       1,                 /* Use busy signal: 1 = use busy, 0 = use time delays */\
       PORTD, TRISD,     /* Data port and data port tris register */ \
       PORTA, TRISA,     /* Control port and control port tris register */ \
       3,                /* Bit number of control port is connected to RS */ \
       2,                /* Bit number of control port is connected to RW */ \
       1                 /* Bit number of control port is connected to Enable */

#include <lcd_driver.h> // include the LCD template code


// Note: If using this code on a device with analog I/O pins (eg PIC16F877), 
// remember to turn off the analog functionality on the pins being used before 
// calling the lcd_setup() function, otherwise you will find that things don't
// work as the port will partly in analog mode!!
////////////////////////////////////////////////////////////////////////////


#ifdef _PIC16
   #pragma DATA _CONFIG, _CP_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC
#else
   #pragma DATA    _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
   #pragma DATA    _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_OFF_2L
   #pragma DATA    _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
   #pragma DATA    _CONFIG3H, _CCP2MX_ON_3H
   #pragma DATA    _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
   #pragma DATA    _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
   #pragma DATA    _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
   #pragma DATA    _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
   #pragma DATA    _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
   #pragma DATA    _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
   #pragma DATA    _CONFIG7H, _EBTRB_OFF_7H
#endif

#pragma CLOCK_FREQ 4000000

void main()
{    
   // most important line that is often forgotten 
   // - turn PortA inputs that we are using into digital mode.
   adcon1 = 00001110b; 
   lcd_setup();
   
   lcd_gotoxy( 0,0 ); // start of first line
   lprintf( "My numb is %u", 1234 );
   
   while( 1 );
}

 

The limitation with lprintf is that it can only have one numerical argument.

So to print out two numbers:

 

lprintf( "numb1:%u", mynumb1 );

lprintf( " numb2:%u", mynumb2 );

 

Regards

Dave

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...