SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on how to get your MSP JTAG programmer up and running.
By sid_s
#51838
hi all,

I have a project in which i have to dynamically display numbers on LCD by taking input from the user, i have done it for integers, can any one guide me how do i implement the same for decimal numbers
Thanx

sid
User avatar
By leon_heller
#51841
Language?

Leon
By sid_s
#51843
C using IAR
User avatar
By leon_heller
#51844
sprintf?

Leon
By sid_s
#51845
can you please tell me how do i use that cause i am new to this kit.
User avatar
By leon_heller
#51846
It's similar to printf (formatted print) but writes to a buffer instead of standard output. Your compiler documentation will explain how to use it, or see a good book on C.

Leon
By sid_s
#51847
thx....
By sid_s
#51852
#include "LCD.h"
#include "msp430xG46x.h"
#include "stdio.h"

/*
#define SEG_A 0x01
#define SEG_B 0x02
#define SEG_C 0x04
#define SEG_D 0x08
#define SEG_E 0x40
#define SEG_F 0x10
#define SEG_G 0x20
#define SEG_H 0x80
*/

const int charseg[]=
{
LCD_A+LCD_B+LCD_C+LCD_D+LCD_E+LCD_F, // '0' or 'O'
LCD_B+LCD_C, // '1' or 'I'
LCD_A+LCD_B+LCD_D+LCD_E+LCD_G, // '2' or 'Z'
LCD_A+LCD_B+LCD_C+LCD_D+LCD_G, // '3'
LCD_B+LCD_C+LCD_F+LCD_G, // '4' or 'y'
LCD_A+LCD_C+LCD_D+LCD_F+LCD_G, // '5' or 'S'
LCD_A+LCD_C+LCD_D+LCD_E+LCD_F+LCD_G, // '6' or 'b'
LCD_A+LCD_B+LCD_C, // '7'
LCD_A+LCD_B+LCD_C+LCD_D+LCD_E+LCD_F+LCD_G, // '8' or 'B'
LCD_A+LCD_B+LCD_C+LCD_F+LCD_G // '9' or 'g'


};

void disp(double num)
{

if(num>18888888)
{
LCDM7=LCD_A+LCD_D+LCD_E+LCD_F+LCD_G;
LCDM6=LCD_E+LCD_G;
LCDM5=LCD_E+LCD_G;
}
else if(num>9999999)
{
LCDMEM[12]|=LCD_D;
}
printf("%.1f", num);


}
void main(void)
{
int i,pos=0,index;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT

FLL_CTL0 |= XCAP14PF; // Configure load caps



P5SEL = 0x1C; // P5.2/3/4 = LCD COM lines
for (i = 19; i > 0; i--) LCDMEM = 0; // Clear LCD
LCDACTL = LCDON + LCD4MUX + LCDFREQ_128; // 4mux LCD, ACLK/128
LCDAPCTL0 = 0x7E; // Segments 4-27


disp(18888890);


}


this is my code under development but m getting
Fatal Error[e89]: Too much object code produced (more than 0x1000 bytes) for this package
this error what do i do please help me
User avatar
By leon_heller
#51853
printf is a large amount of code. You will probably have to write your own much smaller function instead of it.

Leon